Repository: catchpoint/WebPageTest (language: php)

Issue:
Cleanup adult-site-related code
See comment https://github.com/WPO-Foundation/webpagetest/pull/2431#issuecomment-1270712553


Discussion / hints:

Fix patch:
diff --git a/www/include/TestInfo.php b/www/include/TestInfo.php
index 1f2153bd3d..753ee8b468 100644
--- a/www/include/TestInfo.php
+++ b/www/include/TestInfo.php
@@ -211,24 +211,6 @@ public function getTester($run)
         return $tester;
     }
 
-  /**
-   * @param string[] $keywords Keywords to check the info for
-   * @return True if the TestInfo matches the keywords, false otherwise
-   */
-    public function isAdultSite($keywords)
-    {
-        $url = $this->getUrl();
-        if (!$url) {
-            return false;
-        }
-        foreach ($keywords as $keyword) {
-            if (stripos($url, $keyword) !== false) {
-                return true;
-            }
-        }
-        return false;
-    }
-
   /**
    * @return bool True if the test is marked as an test_error, false otherwise
    */
diff --git a/www/include/TestResults.php b/www/include/TestResults.php
index bf077a21d6..3437fff97a 100644
--- a/www/include/TestResults.php
+++ b/www/include/TestResults.php
@@ -214,26 +214,6 @@ public function getMedianRunNumber($metric, $cached, $medianMode = "median")
         return $runNumbers[$medianIndex];
     }
 
-  /**
-   * @param string[] $keywords Keywords to use for the check
-   * @return bool True if the checked site is an adult site, false otherwise
-   */
-    public function isAdultSite($keywords)
-    {
-        if ($this->testInfo->isAdultSite($keywords)) {
-            return true;
-        }
-        for ($i = 0; $i < $this->numRuns; $i++) {
-            if (isset($this->runResults[$i][0]) && $this->runResults[$i][0]->isAdultSite($keywords)) {
-                return true;
-            }
-            if (isset($this->runResults[$i][1]) && $this->runResults[$i][0]->isAdultSite($keywords)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
   /** Return the lighthouse results (from JSON) */
     public function getLighthouseResult()
     {
diff --git a/www/include/TestRunResults.php b/www/include/TestRunResults.php
index 8a825e0979..2f30b9c224 100644
--- a/www/include/TestRunResults.php
+++ b/www/include/TestRunResults.php
@@ -189,23 +189,6 @@ public function aggregateMetric($metric, $successfulOnly = true)
         return $foundMetric ? $aggregated : null;
     }
 
-  /**
-   * @param string[] $keywords Keywords to use for the check
-   * @return bool True if the checked site is an adult site, false otherwise
-   */
-    public function isAdultSite($keywords)
-    {
-        if ($this->testInfo->isAdultSite($keywords)) {
-            return true;
-        }
-        foreach ($this->stepResults as $step) {
-            if ($step->isAdultSite($keywords)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
   /**
    * @param string $metric The metric to compute the average of all steps
    * @return float|null The average metric for all steps having it set or null if not set in any step
diff --git a/www/include/TestStepResult.php b/www/include/TestStepResult.php
index 915c8b80c7..071ec4c02a 100644
--- a/www/include/TestStepResult.php
+++ b/www/include/TestStepResult.php
@@ -312,29 +312,6 @@ public function getStatusMessages()
         return $statusMessages;
     }
 
-  /**
-   * @param string[] $keywords Keywords to use for the check
-   * @return bool True if the checked site is an adult site, false otherwise
-   */
-    public function isAdultSite($keywords)
-    {
-        if ($this->testInfo->isAdultSite($keywords)) {
-            return true;
-        }
-        foreach ($keywords as $keyword) {
-            if (!empty($this->rawData["adult_site"])) {
-                return true;
-            }
-            if (!empty($this->rawData["URL"]) && stripos($this->rawData["URL"], $keyword) !== false) {
-                return true;
-            }
-            if (!empty($this->rawData["title"]) && stripos($this->rawData["title"], $keyword) !== false) {
-                return true;
-            }
-        }
-        return false;
-    }
-
   /**
    * @return bool True if the step has a breakdown timeline, false otherwise
    */
diff --git a/www/settings/adult.txt b/www/settings/adult.txt
deleted file mode 100644
index 689ea653ff..0000000000
--- a/www/settings/adult.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-porn
-tits
-nude
-penis
-dick
-sex
-xxx
-fetish
-fuck
-erotic
-pedophile
-pedophilia
-anal
-bdsm
-beastiality
-blowjob
-bondage
-boobs
-bukkake
-clit
-cock
-cunt
-dildo
-ejaculation
-gloryhole
-orgy
-pussy
-masterbate
-orgasm
-pubic
-mike18
\ No newline at end of file


Test patch: