Verified Commit 57f7daa9 authored by Dave Long's avatar Dave Long
Browse files

Issue #3532724 by catch: PerformanceTestTrait script/stylesheet size counting...

Issue #3532724 by catch: PerformanceTestTrait script/stylesheet size counting needs to handle external URLs
parent e7013351
Loading
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -398,6 +398,10 @@ private function collectNetworkData(array $messages, PerformanceData $performanc
    // not.
    foreach ($stylesheet_urls as $url) {
      $stylesheet_count++;
      if (!str_starts_with($url, $GLOBALS['base_url'])) {
        $stylesheet_bytes += strlen(file_get_contents($url));
      }
      else {
        if ($GLOBALS['base_path'] === '/') {
          $filename = ltrim(parse_url($url, PHP_URL_PATH), '/');
          $stylesheet_bytes += strlen(file_get_contents($filename));
@@ -409,8 +413,13 @@ private function collectNetworkData(array $messages, PerformanceData $performanc
          $stylesheet_bytes += strlen(str_replace($GLOBALS['base_path'], '/', file_get_contents($filename)));
        }
      }
    }
    foreach ($script_urls as $url) {
      $script_count++;
      if (!str_starts_with($url, $GLOBALS['base_url'])) {
        $script_bytes += strlen(file_get_contents($url));
      }
      else {
        if ($GLOBALS['base_path'] === '/') {
          $filename = ltrim(parse_url($url, PHP_URL_PATH), '/');
        }
@@ -419,6 +428,7 @@ private function collectNetworkData(array $messages, PerformanceData $performanc
        }
        $script_bytes += strlen(file_get_contents($filename));
      }
    }

    $performance_data->setStylesheetCount($stylesheet_count);
    $performance_data->setStylesheetBytes($stylesheet_bytes);