diff --git a/core/assets/scaffold/files/default.settings.php b/core/assets/scaffold/files/default.settings.php index ee3b49c0a8..827b6555e9 100644 --- a/core/assets/scaffold/files/default.settings.php +++ b/core/assets/scaffold/files/default.settings.php @@ -616,21 +616,6 @@ # ini_set('pcre.backtrack_limit', 200000); # ini_set('pcre.recursion_limit', 200000); -/** - * Add Permissions-Policy header to disable Google FLoC. - * - * By default, Drupal sends the 'Permissions-Policy: interest-cohort=()' header - * to disable Google's Federated Learning of Cohorts feature, introduced in - * Chrome 89. - * - * See https://en.wikipedia.org/wiki/Federated_Learning_of_Cohorts for more - * information about FLoC. - * - * If you don't wish to disable FLoC in Chrome, you can set this value - * to FALSE. - */ -# $settings['block_interest_cohort'] = TRUE; - /** * Configuration overrides. * diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 2879ae9eab..23f13695d3 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -125,11 +125,6 @@ public function onRespond(ResponseEvent $event) { $response->headers->set('X-Content-Type-Options', 'nosniff', FALSE); $response->headers->set('X-Frame-Options', 'SAMEORIGIN', FALSE); - // Add a Permissions-Policy header to block Federated Learning of Cohorts. - if (Settings::get('block_interest_cohort', TRUE) && !$response->headers->has('Permissions-Policy')) { - $response->headers->set('Permissions-Policy', 'interest-cohort=()'); - } - // If the current response isn't an implementation of the // CacheableResponseInterface, we assume that a Response is either // explicitly not cacheable or that caching headers are already set in diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index aedae4c951..d9b0f9216d 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -37,7 +37,12 @@ final class Settings { * * @see self::handleDeprecations() */ - private static $deprecatedSettings = []; + private static $deprecatedSettings = [ + 'block_interest_cohort' => [ + 'replacement' => '', + 'message' => 'The "block_interest_cohort" setting is deprecated in drupal:9.5.0. This setting should be removed from the settings file, since its usage has been removed. See https://www.drupal.org/node/3320787.', + ], + ]; /** * Constructor. diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 82279b2b10..0af2dcabce 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -5,16 +5,6 @@ parameters: count: 1 path: ../composer/Plugin/Scaffold/Operations/AppendOp.php - - - message: "#^Variable \\$app_root might not be defined\\.$#" - count: 1 - path: assets/scaffold/files/default.settings.php - - - - message: "#^Variable \\$site_path might not be defined\\.$#" - count: 1 - path: assets/scaffold/files/default.settings.php - - message: "#^Function _batch_process invoked with 1 parameter, 0 required\\.$#" count: 1 diff --git a/core/phpstan.neon.dist b/core/phpstan.neon.dist index 881dd8f4e9..0c79dda147 100644 --- a/core/phpstan.neon.dist +++ b/core/phpstan.neon.dist @@ -14,6 +14,7 @@ parameters: excludePaths: # Skip settings. - ../*/settings*.php + - ../*/*.settings*.php # Skip test fixtures. - ../*/node_modules/* - */tests/fixtures/*.php diff --git a/core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php b/core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php deleted file mode 100644 index 10a7b00438..0000000000 --- a/core/tests/Drupal/KernelTests/Core/Http/BlockInterestCohortTest.php +++ /dev/null @@ -1,83 +0,0 @@ -handle($request); - - $this->assertSame('interest-cohort=()', $response->headers->get('Permissions-Policy')); - } - - /** - * Tests that an existing interest-cohort policy is not overwritten. - */ - public function testExistingInterestCohortPolicy() { - $headers['Permissions-Policy'] = 'interest-cohort=*'; - - $kernel = \Drupal::service('http_kernel'); - $request = Request::create('/'); - $response = new Response('', 200, $headers); - $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response); - \Drupal::service('finish_response_subscriber')->onRespond($event); - - $this->assertSame($headers['Permissions-Policy'], $response->headers->get('Permissions-Policy')); - } - - /** - * Tests that an existing header is not modified. - */ - public function testExistingPolicyHeader() { - $headers['Permissions-Policy'] = 'geolocation=()'; - - $kernel = \Drupal::service('http_kernel'); - $request = Request::create('/'); - $response = new Response('', 200, $headers); - $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, $response); - \Drupal::service('finish_response_subscriber')->onRespond($event); - - $this->assertSame($headers['Permissions-Policy'], $response->headers->get('Permissions-Policy')); - } - - /** - * Tests that FLoC blocking is ignored for subrequests. - */ - public function testSubrequestBlocking() { - $request = Request::create('/'); - $response = \Drupal::service('http_kernel')->handle($request, HttpKernelInterface::SUB_REQUEST); - - $this->assertFalse($response->headers->has('Permissions-Policy')); - } - - /** - * Tests that FLoC blocking can be disabled in settings.php. - */ - public function testDisableBlockSetting() { - $settings = Settings::getAll(); - $settings['block_interest_cohort'] = FALSE; - new Settings($settings); - - $request = Request::create('/'); - $response = \Drupal::service('http_kernel')->handle($request); - - $this->assertFalse($response->headers->has('Permissions-Policy')); - } - -} diff --git a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php index 5d860aa139..6e06b8c172 100644 --- a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php +++ b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php @@ -305,7 +305,12 @@ public function testRealDeprecatedSettings(string $legacy_setting, string $expec * Provides data for testRealDeprecatedSettings(). */ public function providerTestRealDeprecatedSettings(): array { - return []; + return [ + [ + 'block_interest_cohort', + 'The "block_interest_cohort" setting is deprecated in drupal:9.5.0. This setting should be removed from the settings file, since its usage has been removed. See https://www.drupal.org/node/3320787.', + ], + ]; } /** diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php index ee3b49c0a8..827b6555e9 100644 --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -616,21 +616,6 @@ # ini_set('pcre.backtrack_limit', 200000); # ini_set('pcre.recursion_limit', 200000); -/** - * Add Permissions-Policy header to disable Google FLoC. - * - * By default, Drupal sends the 'Permissions-Policy: interest-cohort=()' header - * to disable Google's Federated Learning of Cohorts feature, introduced in - * Chrome 89. - * - * See https://en.wikipedia.org/wiki/Federated_Learning_of_Cohorts for more - * information about FLoC. - * - * If you don't wish to disable FLoC in Chrome, you can set this value - * to FALSE. - */ -# $settings['block_interest_cohort'] = TRUE; - /** * Configuration overrides. *