core/includes/file.inc | 2 +- core/lib/Drupal/Core/Asset/CssOptimizer.php | 7 ++----- .../Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php | 2 +- core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/core/includes/file.inc b/core/includes/file.inc index 3e5eb8c..41d01dd 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -216,7 +216,7 @@ function file_create_url($uri) { // If this is not a properly formatted stream, then it is a shipped file. // Therefore, return the urlencoded URI with the base URL prepended. $options = UrlHelper::parse($uri); - $path = $GLOBALS['base_url'] . '/' . UrlHelper::encodePath($options['path']); + $path = $GLOBALS['base_path'] . UrlHelper::encodePath($options['path']); // Append the query. if ($options['query']) { $path .= '?' . UrlHelper::buildQuery($options['query']); diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php index d048a3e..dc34a23 100644 --- a/core/lib/Drupal/Core/Asset/CssOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php @@ -61,17 +61,14 @@ public function clean($contents) { * Build aggregate CSS file. */ protected function processFile($css_asset) { - global $base_path; - $contents = $this->loadFile($css_asset['data'], TRUE); $contents = $this->clean($contents); // Get the parent directory of this file, relative to the Drupal root. $css_base_path = substr($css_asset['data'], 0, strrpos($css_asset['data'], '/')); - // Store base path. Ensure it is a prefix that will result in root-relative - // file URLs. - $this->rewriteFileURIBasePath = $base_path . $css_base_path . '/'; + // Store base path. + $this->rewriteFileURIBasePath = $css_base_path . '/'; // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths. return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', array($this, 'rewriteFileURI'), $contents); diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php index eab4fe4..96f5424 100644 --- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php @@ -20,7 +20,7 @@ * Component/Utility. */ function file_create_url($uri) { - return 'file_create_url:' . $uri; + return 'file_create_url:/' . $uri; } } diff --git a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php index f9a9383..c9b3138 100644 --- a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php @@ -20,7 +20,7 @@ * Component/Utility. */ function file_create_url($uri) { - return 'file_create_url:' . $uri; + return 'file_create_url:/' . $uri; } }