Issue #1824778 by vijaycs85, ACF, pcambra, cam8001: Covert css_gzip_compression() and js_gzip_compression() variables to CMI system.
parent
e4bd0c4537
commit
ac21d7bc11
|
@ -2818,7 +2818,7 @@ function drupal_aggregate_css(&$css_groups) {
|
|||
}
|
||||
else {
|
||||
$config = config('system.performance');
|
||||
$preprocess_css = $config->get('preprocess.css');
|
||||
$preprocess_css = $config->get('css.preprocess');
|
||||
}
|
||||
|
||||
// For each group that needs aggregation, aggregate its items.
|
||||
|
@ -3152,9 +3152,9 @@ function drupal_build_css_cache($css) {
|
|||
// 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_compression to FALSE in order to skip
|
||||
// aren't working can set css.gzip to FALSE in order to skip
|
||||
// generating a file that won't be used.
|
||||
if (variable_get('css_gzip_compression', TRUE) && extension_loaded('zlib')) {
|
||||
if (config('system.performance')->get('css.gzip') && extension_loaded('zlib')) {
|
||||
if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($data, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -3339,7 +3339,7 @@ function drupal_clear_css_cache() {
|
|||
*/
|
||||
function drupal_delete_file_if_stale($uri) {
|
||||
// Default stale file threshold is 30 days.
|
||||
if (REQUEST_TIME - filemtime($uri) > config('system.performance')->get('preprocess.stale_file_threshold')) {
|
||||
if (REQUEST_TIME - filemtime($uri) > config('system.performance')->get('stale_file_threshold')) {
|
||||
file_unmanaged_delete($uri);
|
||||
}
|
||||
}
|
||||
|
@ -4095,7 +4095,7 @@ function drupal_aggregate_js(&$js_groups) {
|
|||
}
|
||||
else {
|
||||
$config = config('system.performance');
|
||||
$preprocess_js = $config->get('preprocess.js');
|
||||
$preprocess_js = $config->get('js.preprocess');
|
||||
}
|
||||
|
||||
if ($preprocess_js) {
|
||||
|
@ -4664,9 +4664,9 @@ function drupal_build_js_cache($files) {
|
|||
// 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 js_gzip_compression to FALSE in order to skip
|
||||
// aren't working can set js.gzip to FALSE in order to skip
|
||||
// generating a file that won't be used.
|
||||
if (variable_get('js_gzip_compression', TRUE) && extension_loaded('zlib')) {
|
||||
if (config('system.performance')->get('js.gzip') && extension_loaded('zlib')) {
|
||||
if (!file_exists($uri . '.gz') && !file_unmanaged_save_data(gzencode($contents, 9, FORCE_GZIP), $uri . '.gz', FILE_EXISTS_REPLACE)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ class ColorTest extends WebTestBase {
|
|||
|
||||
// Test with aggregated CSS turned on.
|
||||
$config = config('system.performance');
|
||||
$config->set('preprocess.css', 1);
|
||||
$config->set('css.preprocess', 1);
|
||||
$config->save();
|
||||
$this->drupalGet('<front>');
|
||||
$stylesheets = variable_get('drupal_css_cache_files', array());
|
||||
|
@ -114,7 +114,7 @@ class ColorTest extends WebTestBase {
|
|||
$stylesheet_content .= join("\n", file(drupal_realpath($uri)));
|
||||
}
|
||||
$this->assertTrue(strpos($stylesheet_content, 'public://') === FALSE, 'Make sure the color paths have been translated to local paths. (' . $theme . ')');
|
||||
$config->set('preprocess.css', 0);
|
||||
$config->set('css.preprocess', 0);
|
||||
$config->save();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,12 @@ cache:
|
|||
page:
|
||||
enabled: '0'
|
||||
max_age: '0'
|
||||
preprocess:
|
||||
css: '0'
|
||||
js: '0'
|
||||
stale_file_threshold: '2592000'
|
||||
css:
|
||||
preprocess: '0'
|
||||
gzip: '1'
|
||||
js:
|
||||
preprocess: '0'
|
||||
gzip: '1'
|
||||
response:
|
||||
gzip: '0'
|
||||
stale_file_threshold: '2592000'
|
||||
|
|
|
@ -39,8 +39,8 @@ class JavaScriptTest extends WebTestBase {
|
|||
|
||||
// Disable preprocessing
|
||||
$config = config('system.performance');
|
||||
$this->preprocess_js = $config->get('preprocess.js');
|
||||
$config->set('preprocess.js', 0);
|
||||
$this->preprocess_js = $config->get('js.preprocess');
|
||||
$config->set('js.preprocess', 0);
|
||||
$config->save();
|
||||
|
||||
// Reset drupal_add_js() and drupal_add_library() statics before each test.
|
||||
|
@ -51,7 +51,7 @@ class JavaScriptTest extends WebTestBase {
|
|||
function tearDown() {
|
||||
// Restore configured value for JavaScript preprocessing.
|
||||
$config = config('system.performance');
|
||||
$config->set('preprocess.js', $this->preprocess_js);
|
||||
$config->set('js.preprocess', $this->preprocess_js);
|
||||
$config->save();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class JavaScriptTest extends WebTestBase {
|
|||
*/
|
||||
function testAggregatedAttributes() {
|
||||
// Enable aggregation.
|
||||
config('system.performance')->set('preprocess.js', 1)->save();
|
||||
config('system.performance')->set('js.preprocess', 1)->save();
|
||||
|
||||
$default_query_string = variable_get('css_js_query_string', '0');
|
||||
|
||||
|
@ -311,7 +311,7 @@ class JavaScriptTest extends WebTestBase {
|
|||
// 'every_page' files, and one file is made for the others.
|
||||
drupal_static_reset('drupal_add_js');
|
||||
$config = config('system.performance');
|
||||
$config->set('preprocess.js', 1);
|
||||
$config->set('js.preprocess', 1);
|
||||
$config->save();
|
||||
drupal_add_library('system', 'drupal');
|
||||
drupal_add_js('core/misc/ajax.js');
|
||||
|
@ -332,7 +332,7 @@ class JavaScriptTest extends WebTestBase {
|
|||
*/
|
||||
function testAggregationOrder() {
|
||||
// Enable JavaScript aggregation.
|
||||
config('system.performance')->set('preprocess.js', 1)->save();
|
||||
config('system.performance')->set('js.preprocess', 1)->save();
|
||||
drupal_static_reset('drupal_add_js');
|
||||
|
||||
// Add two JavaScript files to the current request and build the cache.
|
||||
|
|
|
@ -112,7 +112,7 @@ class ThemeTest extends WebTestBase {
|
|||
// so it doesn't matter what page we get, as long as it is themed with the
|
||||
// test theme. First we test with CSS aggregation disabled.
|
||||
$config = config('system.performance');
|
||||
$config->set('preprocess.css', 0);
|
||||
$config->set('css.preprocess', 0);
|
||||
$config->save();
|
||||
$this->drupalGet('theme-test/suggestion');
|
||||
$this->assertNoText('system.base.css', 'The theme\'s .info file is able to override a module CSS file from being added to the page.');
|
||||
|
@ -121,10 +121,10 @@ class ThemeTest extends WebTestBase {
|
|||
// triggered during drupal_build_css_cache() when a source file doesn't
|
||||
// exist. Then allow remaining tests to continue with aggregation disabled
|
||||
// by default.
|
||||
$config->set('preprocess.css', 1);
|
||||
$config->set('css.preprocess', 1);
|
||||
$config->save();
|
||||
$this->drupalGet('theme-test/suggestion');
|
||||
$config->set('preprocess.css', 0);
|
||||
$config->set('css.preprocess', 0);
|
||||
$config->save();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ class SystemUpgradePathTest extends UpgradePathTestBase {
|
|||
'cache.page.enabled' => '1',
|
||||
'cache.page.max_age' => '1800',
|
||||
'response.gzip' => '1',
|
||||
'preprocess.js' => '1',
|
||||
'preprocess.css' => '1',
|
||||
'js.preprocess' => '1',
|
||||
'css.preprocess' => '1',
|
||||
);
|
||||
|
||||
$expected_config['system.rss'] = array(
|
||||
|
|
|
@ -1664,13 +1664,13 @@ function system_performance_settings($form, &$form_state) {
|
|||
$form['bandwidth_optimization']['preprocess_css'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Aggregate and compress CSS files.'),
|
||||
'#default_value' => $config->get('preprocess.css'),
|
||||
'#default_value' => $config->get('css.preprocess'),
|
||||
'#disabled' => $disabled,
|
||||
);
|
||||
$form['bandwidth_optimization']['preprocess_js'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Aggregate JavaScript files.'),
|
||||
'#default_value' => $config->get('preprocess.js'),
|
||||
'#default_value' => $config->get('js.preprocess'),
|
||||
'#disabled' => $disabled,
|
||||
);
|
||||
|
||||
|
@ -1694,8 +1694,8 @@ function system_performance_settings_submit($form, &$form_state) {
|
|||
$config->set('cache.page.enabled', $form_state['values']['cache']);
|
||||
$config->set('cache.page.max_age', $form_state['values']['page_cache_maximum_age']);
|
||||
$config->set('response.gzip', $form_state['values']['page_compression']);
|
||||
$config->set('preprocess.css', $form_state['values']['preprocess_css']);
|
||||
$config->set('preprocess.js', $form_state['values']['preprocess_js']);
|
||||
$config->set('css.preprocess', $form_state['values']['preprocess_css']);
|
||||
$config->set('js.preprocess', $form_state['values']['preprocess_js']);
|
||||
$config->save();
|
||||
}
|
||||
|
||||
|
|
|
@ -1940,9 +1940,9 @@ function system_update_8017() {
|
|||
'cache' => 'cache.page.enabled',
|
||||
'page_cache_maximum_age' => 'cache.page.max_age',
|
||||
'page_compression' => 'response.gzip',
|
||||
'preprocess_css' => 'preprocess.css',
|
||||
'preprocess_js' => 'preprocess.js',
|
||||
'stale_file_threshold' => 'preprocess.stale_file_threshold',
|
||||
'preprocess_css' => 'css.preprocess',
|
||||
'preprocess_js' => 'js.preprocess',
|
||||
'stale_file_threshold' => 'stale_file_threshold',
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -2304,6 +2304,19 @@ function system_update_8039() {
|
|||
update_variables_to_config('system.site', $variable_map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts css and js gzip compression variables to config.
|
||||
*
|
||||
* @ingroup config_upgrade
|
||||
*/
|
||||
function system_update_8040() {
|
||||
$variable_map = array(
|
||||
'css_gzip_compression' => 'css.gzip',
|
||||
'js_gzip_compression' => 'js.gzip'
|
||||
);
|
||||
update_variables_to_config('system.performance', $variable_map);
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "defgroup updates-7.x-to-8.x".
|
||||
* The next series of updates should start at 9000.
|
||||
|
|
|
@ -458,8 +458,8 @@ ini_set('session.cookie_lifetime', 2000000);
|
|||
* configured to cache and compress these files itself you may want to uncomment
|
||||
* one or both of the below lines, which will prevent gzip files being stored.
|
||||
*/
|
||||
# $conf['css_gzip_compression'] = FALSE;
|
||||
# $conf['js_gzip_compression'] = FALSE;
|
||||
# $conf['system.performance']['css.gzip'] = FALSE;
|
||||
# $conf['system.performance']['js.gzip'] = FALSE;
|
||||
|
||||
/**
|
||||
* String overrides:
|
||||
|
|
Loading…
Reference in New Issue