diff --git a/core/includes/common.inc b/core/includes/common.inc index c513411..4742eb0 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4717,7 +4717,7 @@ function drupal_flush_all_caches() { */ function _drupal_flush_css_js() { // The timestamp is converted to base 36 in order to make it more compact. - variable_set('css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); + Drupal::state()->set('system.css_js_query_string', base_convert(REQUEST_TIME, 10, 36)); } /** diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 0a1252d..397b090 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -422,6 +422,13 @@ function install_begin_request(&$install_state) { )) ->addMethodCall('setUserAgent', array('Drupal (+http://drupal.org/)')); + $container->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory') + ->addArgument(new Reference('service_container')); + $container->register('keyvalue.memory', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory'); + // Override the default keyvalue storage to use memory as the database is + // not available. + $conf['keyvalue_default'] = 'keyvalue.memory'; + // Register the expirable key value store used by form cache. $container ->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueExpirableFactory') @@ -1201,7 +1208,7 @@ function install_database_errors($database, $settings_file) { * @see install_settings_form_validate() */ function install_settings_form_submit($form, &$form_state) { - global $install_state; + global $install_state, $conf; // Update global settings array and save. $settings = array(); @@ -1239,6 +1246,10 @@ function install_settings_form_submit($form, &$form_state) { // Add the config directories to settings.php. drupal_install_config_directories(); + // The container is about to be rebuilt so we need to unset the keyvalue + // storage override that the installer is using. + unset($conf['keyvalue_default']); + // Indicate that the settings file has been verified, and check the database // for the last completed task, now that we have a valid connection. This // last step is important since we want to trigger an error if the new diff --git a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php index 6d36ede..aa700d0 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php @@ -24,7 +24,7 @@ public function render(array $css_assets) { // browser-caching. The string changes on every update or full cache // flush, forcing browsers to load a new copy of the files, as the // URL changed. - $query_string = variable_get('css_js_query_string', '0'); + $query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; // Defaults for LINK and STYLE elements. $link_element_defaults = array( diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php index b9f6582..ee13f5f 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php @@ -1,5 +1,6 @@ get('system.css_js_query_string') ?: '0'; // For inline JavaScript to validate as XHTML, all JavaScript containing // XHTML needs to be wrapped in CDATA. To make that backwards compatible diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php index 54abcba..ebb3c0b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php @@ -78,7 +78,7 @@ function testRenderFile() { $styles = drupal_get_css(); $this->assertTrue(strpos($styles, $css) > 0, 'Rendered CSS includes the added stylesheet.'); // Verify that newlines are properly added inside style tags. - $query_string = variable_get('css_js_query_string', '0'); + $query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; $css_processed = ''; $this->assertEqual(trim($styles), $css_processed, 'Rendered CSS includes newlines inside style tags for JavaScript use.'); } @@ -184,7 +184,7 @@ function testAddCssFileWithQueryString() { drupal_add_css($css_with_query_string); $styles = drupal_get_css(); - $query_string = variable_get('css_js_query_string', '0'); + $query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; $this->assertTrue(strpos($styles, $css_without_query_string . '?' . $query_string), 'Query string was appended correctly to css.'); $this->assertTrue(strpos($styles, str_replace('&', '&', $css_with_query_string)), 'Query string not escaped on a URI.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php index 783eab2..e23d946 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php @@ -101,7 +101,7 @@ function testAddExternal() { * Tests adding JavaScript files with additional attributes. */ function testAttributes() { - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; drupal_add_library('system', 'drupal'); drupal_add_js('http://example.com/script.js', array('attributes' => array('defer' => 'defer'))); @@ -122,7 +122,7 @@ function testAggregatedAttributes() { // Enable aggregation. config('system.performance')->set('js.preprocess', 1)->save(); - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; drupal_add_library('system', 'drupal'); drupal_add_js('http://example.com/script.js', array('attributes' => array('defer' => 'defer'))); @@ -275,7 +275,7 @@ function testDifferentWeight() { * @see drupal_pre_render_conditional_comments() */ function testBrowserConditionalComments() { - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; drupal_add_library('system', 'drupal'); drupal_add_js('core/misc/collapse.js', array('browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE))); @@ -304,7 +304,7 @@ function testVersionQueryString() { * Tests JavaScript grouping and aggregation. */ function testAggregation() { - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; // To optimize aggregation, items with the 'every_page' option are ordered // ahead of ones without. The order of JavaScript execution must be the @@ -562,7 +562,7 @@ function testAddJsFileWithQueryString() { $js = drupal_get_path('module', 'node') . '/node.js'; drupal_add_js($js); - $query_string = variable_get('css_js_query_string', '0'); + $query_string = \Drupal::state()->get('system.css_js_query_string') ?: '0'; $scripts = drupal_get_js(); $this->assertTrue(strpos($scripts, $js . '?' . $query_string), 'Query string was appended correctly to JS.'); } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 6c170da..df9bfe0 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1725,12 +1725,13 @@ function system_update_8031() { } /** - * Remove the drupal_js_cache_files variable. + * Remove the drupal_js_cache_files and css_js_query_string variables. * * @ingroup config_upgrade */ function system_update_8032() { update_variable_del('drupal_js_cache_files'); + update_variable_del('css_js_query_string'); } /**