diff --git a/core/includes/common.inc b/core/includes/common.inc index aea8529..ded16a3 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -3001,7 +3001,7 @@ function drupal_pre_render_styles($elements) { // 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 = state()->get('css_js_query_string') ?: '0'; // For inline CSS to validate as XHTML, all CSS containing XHTML needs to be // wrapped in CDATA. To make that backwards compatible with HTML 4, we need to @@ -3996,7 +3996,7 @@ function drupal_pre_render_scripts($elements) { // URL changed. Files that should not be cached (see drupal_add_js()) // get REQUEST_TIME as query-string instead, to enforce reload on every // page request. - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = state()->get('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 @@ -6848,7 +6848,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)); + state()->set('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 17e2a66..2867110 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -289,6 +289,10 @@ function install_begin_request(&$install_state) { // Determine whether the configuration system is ready to operate. $install_state['config_verified'] = install_verify_config_directory(CONFIG_ACTIVE_DIRECTORY) && install_verify_config_directory(CONFIG_STAGING_DIRECTORY); + // Check existing settings.php. + $install_state['database_verified'] = install_verify_database_settings(); + $install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified']; + // If it is not, replace the configuration storage with the InstallStorage // implementation, for the following reasons: // - The first call into drupal_container() will try to set up the regular @@ -328,6 +332,15 @@ function install_begin_request(&$install_state) { drupal_container($container); } + // If there is no database then use MemoryStorage for state. + // This allows any state() functions to work in the installer before the + // database has been installed. + if (!$install_state['database_verified']) { + drupal_container() + ->register('state.storage', 'Drupal\Core\KeyValueStore\MemoryStorage') + ->addArgument('state'); + } + // Set up $language, so t() caller functions will still work. drupal_language_initialize(); @@ -367,10 +380,6 @@ function install_begin_request(&$install_state) { // accessing the database before it is set up yet.) drupal_maintenance_theme(); - // Check existing settings.php. - $install_state['database_verified'] = install_verify_database_settings(); - $install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified']; - if ($install_state['database_verified']) { // Initialize the database system. Note that the connection // won't be initialized until it is actually requested. 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 0268756..566a263 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php @@ -98,7 +98,7 @@ class CascadingStylesheetsTest extends WebTestBase { $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 = state()->get('css_js_query_string') ?: '0'; $css_processed = ""; $this->assertEqual(trim($styles), $css_processed, 'Rendered CSS includes newlines inside style tags for JavaScript use.'); } @@ -249,7 +249,7 @@ class CascadingStylesheetsTest extends WebTestBase { */ function testAddCssFileWithQueryString() { $this->drupalGet('common-test/query-string'); - $query_string = variable_get('css_js_query_string', '0'); + $query_string = state()->get('css_js_query_string') ?: '0'; $this->assertRaw(drupal_get_path('module', 'node') . '/node.admin.css?' . $query_string, 'Query string was appended correctly to css.'); $this->assertRaw(drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2', '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 9507e3b..25c5069 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php @@ -100,7 +100,7 @@ class JavaScriptTest extends WebTestBase { * Tests adding external JavaScript Files with the async attribute. */ function testAsyncAttribute() { - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = state()->get('css_js_query_string') ?: '0'; drupal_add_library('system', 'drupal'); drupal_add_js('http://example.com/script.js', array('async' => TRUE)); @@ -118,7 +118,7 @@ class JavaScriptTest extends WebTestBase { * Tests adding external JavaScript Files with the defer attribute. */ function testDeferAttribute() { - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = state()->get('css_js_query_string') ?: '0'; drupal_add_library('system', 'drupal'); drupal_add_js('http://example.com/script.js', array('defer' => TRUE)); @@ -255,7 +255,7 @@ class JavaScriptTest extends WebTestBase { * @see drupal_pre_render_conditional_comments() */ function testBrowserConditionalComments() { - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = state()->get('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))); @@ -284,7 +284,7 @@ class JavaScriptTest extends WebTestBase { * Test JavaScript grouping and aggregation. */ function testAggregation() { - $default_query_string = variable_get('css_js_query_string', '0'); + $default_query_string = state()->get('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 @@ -528,7 +528,7 @@ class JavaScriptTest extends WebTestBase { */ function testAddJsFileWithQueryString() { $this->drupalGet('common-test/query-string'); - $query_string = variable_get('css_js_query_string', '0'); + $query_string = state()->get('css_js_query_string') ?: '0'; $this->assertRaw(drupal_get_path('module', 'node') . '/node.js?' . $query_string, 'Query string was appended correctly to js.'); } }