From 0a4f122fcbf096ea32556e268aa8de21b0d015c1 Mon Sep 17 00:00:00 2001 From: Dave Long Date: Fri, 17 May 2024 10:28:17 +0100 Subject: [PATCH] Issue #3439591 by quietone, mstrelan, pradhumanjain2311, andypost, catch, mfb, longwave, coaston, penyaskito: Add composer dependency on ext-zlib --- composer.lock | 3 ++- core/composer.json | 1 + core/lib/Drupal/Component/Utility/UrlHelper.php | 6 ------ core/lib/Drupal/Core/Asset/AssetDumper.php | 17 ++++++++--------- .../Update/UpdatePathTestBase.php | 11 ----------- 5 files changed, 11 insertions(+), 27 deletions(-) diff --git a/composer.lock b/composer.lock index 2271aabbb46..4e92f77ee38 100644 --- a/composer.lock +++ b/composer.lock @@ -495,7 +495,7 @@ "dist": { "type": "path", "url": "core", - "reference": "a04ae36ab48fdc8d48a813f739cdfeeddb7517eb" + "reference": "ff1a97312bafb66b9f39cc05fa161d99956a15be" }, "require": { "asm89/stack-cors": "^2.1", @@ -517,6 +517,7 @@ "ext-spl": "*", "ext-tokenizer": "*", "ext-xml": "*", + "ext-zlib": "*", "guzzlehttp/guzzle": "^7.5", "guzzlehttp/psr7": "^2.4.5", "masterminds/html5": "^2.7", diff --git a/core/composer.json b/core/composer.json index bf9d3ca6220..62391fa570e 100644 --- a/core/composer.json +++ b/core/composer.json @@ -17,6 +17,7 @@ "ext-SPL": "*", "ext-tokenizer": "*", "ext-xml": "*", + "ext-zlib": "*", "php": ">=8.3.0", "symfony/console": "^7.1@beta", "symfony/dependency-injection": "^7.1@beta", diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php index 14ae12a8e8b..1f5cc9145c5 100644 --- a/core/lib/Drupal/Component/Utility/UrlHelper.php +++ b/core/lib/Drupal/Component/Utility/UrlHelper.php @@ -80,9 +80,6 @@ class UrlHelper { * The data compressed into a URL-safe string. */ public static function compressQueryParameter(string $data): string { - if (!\extension_loaded('zlib')) { - return $data; - } // Use 'base64url' encoding. Note that the '=' sign is only used for padding // on the right of the string, and is otherwise not part of the data. // @see https://datatracker.ietf.org/doc/html/rfc4648#section-5 @@ -104,9 +101,6 @@ class UrlHelper { * uncompressed. */ public static function uncompressQueryParameter(string $compressed): string { - if (!\extension_loaded('zlib')) { - return $compressed; - } // Because this comes from user data, suppress the PHP warning that // gzcompress() throws if the base64-encoded string is invalid. $return = @gzuncompress(base64_decode(str_replace(['-', '_'], ['+', '/'], $compressed))); diff --git a/core/lib/Drupal/Core/Asset/AssetDumper.php b/core/lib/Drupal/Core/Asset/AssetDumper.php index c01b5f3b636..1b85eb63c87 100644 --- a/core/lib/Drupal/Core/Asset/AssetDumper.php +++ b/core/lib/Drupal/Core/Asset/AssetDumper.php @@ -60,15 +60,14 @@ class AssetDumper implements AssetDumperUriInterface { catch (FileException $e) { return FALSE; } - // If CSS/JS gzip compression is enabled and the zlib extension is available - // then create a gzipped version of this file. This file is served - // conditionally to browsers that accept gzip using .htaccess rules. - // It's possible that the rewrite rules in .htaccess aren't working on this - // server, but there's no harm (other than the time spent generating the - // file) in generating the file anyway. Sites on servers where rewrite rules - // aren't working can set css.gzip to FALSE in order to skip - // generating a file that won't be used. - if (extension_loaded('zlib') && \Drupal::config('system.performance')->get($file_extension . '.gzip')) { + // If CSS/JS gzip compression is enabled then create a gzipped version of + // this file. This file is served conditionally to browsers that accept gzip + // using .htaccess rules. It's possible that the rewrite rules in .htaccess + // aren't working on this server, but there's no harm (other than the time + // spent generating the file) in generating the file anyway. Sites on + // servers where rewrite rules aren't working can set css.gzip to FALSE in + // order to skip generating a file that won't be used. + if (\Drupal::config('system.performance')->get($file_extension . '.gzip')) { try { if (!file_exists($uri . '.gz') && !$this->fileSystem->saveData(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FileExists::Replace)) { return FALSE; diff --git a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php index a6f2dd3a4c6..e15351e238d 100644 --- a/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php +++ b/core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php @@ -84,17 +84,6 @@ abstract class UpdatePathTestBase extends BrowserTestBase { */ protected $strictConfigSchema = FALSE; - /** - * {@inheritdoc} - */ - protected function setUp(): void { - if (!extension_loaded('zlib')) { - $this->markTestSkipped('The zlib extension is not available.'); - } - - parent::setUp(); - } - /** * Overrides BrowserTestBase::installDrupal() for update testing. *