Issue #2775381 by mcdruid, Wim Leers, catch, znerol, naveenvalecha: response.gzip is redundant and should be removed
parent
7626a3d70b
commit
bae3b3d7a6
|
@ -133,23 +133,6 @@ class PageCache implements HttpKernelInterface {
|
|||
$response->setPrivate();
|
||||
}
|
||||
|
||||
// Negotiate whether to use compression.
|
||||
if (extension_loaded('zlib') && $response->headers->get('Content-Encoding') === 'gzip') {
|
||||
if (strpos($request->headers->get('Accept-Encoding'), 'gzip') !== FALSE) {
|
||||
// The response content is already gzip'ed, so make sure
|
||||
// zlib.output_compression does not compress it once more.
|
||||
ini_set('zlib.output_compression', '0');
|
||||
}
|
||||
else {
|
||||
// The client does not support compression. Decompress the content and
|
||||
// remove the Content-Encoding header.
|
||||
$content = $response->getContent();
|
||||
$content = gzinflate(substr(substr($content, 10), 0, -8));
|
||||
$response->setContent($content);
|
||||
$response->headers->remove('Content-Encoding');
|
||||
}
|
||||
}
|
||||
|
||||
// Perform HTTP revalidation.
|
||||
// @todo Use Response::isNotModified() as
|
||||
// per https://www.drupal.org/node/2259489.
|
||||
|
@ -181,14 +164,6 @@ class PageCache implements HttpKernelInterface {
|
|||
/**
|
||||
* Fetches a response from the backend and stores it in the cache.
|
||||
*
|
||||
* If page_compression is enabled, a gzipped version of the page is stored in
|
||||
* the cache to avoid compressing the output on each request. The cache entry
|
||||
* is unzipped in the relatively rare event that the page is requested by a
|
||||
* client without gzip support.
|
||||
*
|
||||
* Page compression requires the PHP zlib extension
|
||||
* (http://php.net/manual/ref.zlib.php).
|
||||
*
|
||||
* @see drupal_page_header()
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
|
|
|
@ -222,7 +222,6 @@ class PageCacheTest extends WebTestBase {
|
|||
public function testPageCache() {
|
||||
$config = $this->config('system.performance');
|
||||
$config->set('cache.page.max_age', 300);
|
||||
$config->set('response.gzip', 1);
|
||||
$config->save();
|
||||
|
||||
// Fill the cache.
|
||||
|
|
|
@ -188,13 +188,6 @@ system.performance:
|
|||
gzip:
|
||||
type: boolean
|
||||
label: 'Compress JavaScript files.'
|
||||
response:
|
||||
type: mapping
|
||||
label: 'Response performance settings'
|
||||
mapping:
|
||||
gzip:
|
||||
type: boolean
|
||||
label: 'Compress cached pages'
|
||||
stale_file_threshold:
|
||||
type: integer
|
||||
label: 'Stale file threshold'
|
||||
|
|
|
@ -14,7 +14,6 @@ process:
|
|||
'css/preprocess': preprocess_css
|
||||
'js/preprocess': preprocess_js
|
||||
'cache/page/max_age': cache_lifetime
|
||||
'response/gzip': page_compression
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.performance
|
||||
|
|
|
@ -13,7 +13,6 @@ process:
|
|||
'css/preprocess': preprocess_css
|
||||
'js/preprocess': preprocess_js
|
||||
'cache/page/max_age': cache_lifetime
|
||||
'response/gzip': page_compression
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.performance
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\system\Tests\Update;
|
||||
|
||||
/**
|
||||
* Ensures that response.gzip is removed from system.performance configuration.
|
||||
*
|
||||
* @group Update
|
||||
*/
|
||||
class RemoveResponseGzipFromSystemPerformanceConfigurationTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that response.gzip is removed from system.performance
|
||||
* configuration.
|
||||
*/
|
||||
public function testUpdate() {
|
||||
\Drupal::configFactory()->getEditable('system.performance')
|
||||
->set('response.gzip', 1)
|
||||
->save();
|
||||
|
||||
$this->runUpdates();
|
||||
|
||||
$system_performance = \Drupal::config('system.performance')->get();
|
||||
$this->assertFalse(isset($system_performance['response.gzip']), 'Configuration response.gzip has been removed from system.performance.');
|
||||
}
|
||||
|
||||
}
|
|
@ -1974,3 +1974,13 @@ function system_update_8400(&$sandbox) {
|
|||
|
||||
$sandbox['#finished'] = $sandbox['current'] == $sandbox['max'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove response.gzip (and response) from system module configuration.
|
||||
*/
|
||||
function system_update_8401() {
|
||||
\Drupal::configFactory()->getEditable('system.performance')
|
||||
->clear('response.gzip')
|
||||
->clear('response')
|
||||
->save();
|
||||
}
|
||||
|
|
|
@ -92,9 +92,6 @@ class MigrateSystemConfigurationTest extends MigrateDrupal6TestBase {
|
|||
],
|
||||
// stale_file_threshold is not handled by the migration.
|
||||
'stale_file_threshold' => 2592000,
|
||||
'response' => [
|
||||
'gzip' => TRUE,
|
||||
],
|
||||
],
|
||||
'system.rss' => [
|
||||
// channel is not handled by the migration.
|
||||
|
|
|
@ -95,9 +95,6 @@ class MigrateSystemConfigurationTest extends MigrateDrupal7TestBase {
|
|||
],
|
||||
// stale_file_threshold is not handled by the migration.
|
||||
'stale_file_threshold' => 2592000,
|
||||
'response' => [
|
||||
'gzip' => TRUE,
|
||||
],
|
||||
],
|
||||
'system.rss' => [
|
||||
'channel' => [
|
||||
|
|
Loading…
Reference in New Issue