diff --git a/core/lib/Drupal/Core/StreamWrapper/AssetsStream.php b/core/lib/Drupal/Core/StreamWrapper/AssetsStream.php index 9e29c0b8a934f53e14c32fc485f760dcfd1e63dd..85944dd110be6cc42285cf41ecd2761f349268fc 100644 --- a/core/lib/Drupal/Core/StreamWrapper/AssetsStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/AssetsStream.php @@ -41,7 +41,7 @@ public function getDescription(): string { public static function basePath($site_path = NULL): string { return Settings::get( 'file_assets_path', - Settings::get('file_public_path', 'sites/default/files') + parent::basePath($site_path) ); } diff --git a/core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php b/core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php index 48337977968d49604541e03667ebccef85fe84e4..47bdd8ab081fce3ccfe12c3817c98e8dcbb97bd1 100644 --- a/core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php +++ b/core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php @@ -33,11 +33,36 @@ class AssetOptimizationTest extends BrowserTestBase { * Tests that asset aggregates are rendered and created on disk. */ public function testAssetAggregation(): void { + // Test aggregation with a custom file_assets_path. $this->fileAssetsPath = $this->publicFilesDirectory . '/test-assets'; $settings['settings']['file_assets_path'] = (object) [ 'value' => $this->fileAssetsPath, 'required' => TRUE, ]; + $this->doTestAggregation($settings); + + // Test aggregation with no configured file_assets_path or file_public_path, + // since tests run in a multisite, this tests multisite installs where + // settings.php is the default. + $this->fileAssetsPath = $this->publicFilesDirectory; + $settings['settings']['file_public_path'] = (object) [ + 'value' => NULL, + 'required' => TRUE, + ]; + $settings['settings']['file_assets_path'] = (object) [ + 'value' => NULL, + 'required' => TRUE, + ]; + $this->doTestAggregation($settings); + } + + /** + * Helper to test aggregate file URLs. + * + * @param array $settings + * A settings array to pass to ::writeSettings() + */ + protected function doTestAggregation(array $settings): void { $this->writeSettings($settings); $this->rebuildAll(); $this->config('system.performance')->set('css', [