diff --git a/core/authorize.php b/core/authorize.php index ecb7e22..fd9e2f4 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -69,15 +69,9 @@ function authorize_access_allowed() { require_once __DIR__ . '/includes/module.inc'; require_once __DIR__ . '/includes/ajax.inc'; -// We prepare only a minimal bootstrap. This includes the database and -// variables, however, so we have access to the class autoloader. -drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); - -$request = Request::createFromGlobals(); -\Drupal::getContainer()->set('request', $request); - -// This must go after drupal_bootstrap(), which unsets globals! -global $conf; +// Prepare a minimal bootstrap. +drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE); +$request = \Drupal::request(); // We have to enable the user and system modules, even to check access and // display errors via the maintenance theme. diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 1568f45..01f9710 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -138,19 +138,14 @@ const DRUPAL_BOOTSTRAP_PAGE_CACHE = 2; /** - * Fourth bootstrap phase: initialize the variable system. + * Fourth bootstrap phase: load code for subsystems and modules. */ -const DRUPAL_BOOTSTRAP_VARIABLES = 3; - -/** - * Fifth bootstrap phase: load code for subsystems and modules. - */ -const DRUPAL_BOOTSTRAP_CODE = 4; +const DRUPAL_BOOTSTRAP_CODE = 3; /** * Final bootstrap phase: initialize language, path, theme, and modules. */ -const DRUPAL_BOOTSTRAP_FULL = 5; +const DRUPAL_BOOTSTRAP_FULL = 4; /** * Role ID for anonymous users; should match what's in the "role" table. @@ -816,124 +811,6 @@ function settings() { } /** - * Loads the persistent variable table. - * - * The variable table is composed of values that have been saved in the table - * with variable_set() as well as those explicitly specified in the - * configuration file. - */ -function variable_initialize($conf = array()) { - // NOTE: caching the variables improves performance by 20% when serving - // cached pages. - if ($cached = cache('bootstrap')->get('variables')) { - $variables = $cached->data; - } - else { - // Cache miss. Avoid a stampede. - $name = 'variable_init'; - $lock = \Drupal::lock(); - if (!$lock->acquire($name, 1)) { - // Another request is building the variable cache. - // Wait, then re-run this function. - $lock->wait($name); - return variable_initialize($conf); - } - else { - // Proceed with variable rebuild. - $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed()); - cache('bootstrap')->set('variables', $variables); - $lock->release($name); - } - } - - foreach ($conf as $name => $value) { - $variables[$name] = $value; - } - - return $variables; -} - -/** - * Returns a persistent variable. - * - * Case-sensitivity of the variable_* functions depends on the database - * collation used. To avoid problems, always use lower case for persistent - * variable names. - * - * @param $name - * The name of the variable to return. - * @param $default - * The default value to use if this variable has never been set. - * - * @return - * The value of the variable. Unserialization is taken care of as necessary. - * - * @deprecated This will be removed in Drupal 8.0. Instead, use the - * configuration API. - * - * @see \Drupal\Core\Config::get() - */ -function variable_get($name, $default = NULL) { - global $conf; - - return isset($conf[$name]) ? $conf[$name] : $default; -} - -/** - * Sets a persistent variable. - * - * Case-sensitivity of the variable_* functions depends on the database - * collation used. To avoid problems, always use lower case for persistent - * variable names. - * - * @param $name - * The name of the variable to set. - * @param $value - * The value to set. This can be any PHP data type; these functions take care - * of serialization as necessary. - * - * @deprecated This will be removed in Drupal 8.0. Instead, use the - * configuration API. - * - * @see \Drupal\Core\Config::set() - */ -function variable_set($name, $value) { - global $conf; - - db_merge('variable')->key(array('name' => $name))->fields(array('value' => serialize($value)))->execute(); - - cache('bootstrap')->delete('variables'); - - $conf[$name] = $value; -} - -/** - * Unsets a persistent variable. - * - * Case-sensitivity of the variable_* functions depends on the database - * collation used. To avoid problems, always use lower case for persistent - * variable names. - * - * @param $name - * The name of the variable to undefine. - * - * @deprecated This will be removed in Drupal 8.0. Instead, use the - * configuration API. - * - * @see \Drupal\Core\Config::clear() - */ -function variable_del($name) { - global $conf; - - db_delete('variable') - ->condition('name', $name) - ->execute(); - cache('bootstrap')->delete('variables'); - - unset($conf[$name]); -} - -/** * Gets the page cache cid for this request. * * @param \Symfony\Component\HttpFoundation\Request $request @@ -1743,7 +1620,6 @@ function drupal_anonymous_user() { * - DRUPAL_BOOTSTRAP_CONFIGURATION: Initializes configuration. * - DRUPAL_BOOTSTRAP_KERNEL: Initalizes a kernel. * - DRUPAL_BOOTSTRAP_PAGE_CACHE: Tries to serve a cached page. - * - DRUPAL_BOOTSTRAP_VARIABLES: Initializes the variable system. * - DRUPAL_BOOTSTRAP_CODE: Loads code for subsystems and modules. * - DRUPAL_BOOTSTRAP_FULL: Fully loads Drupal. Validates and fixes input * data. @@ -1760,7 +1636,6 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) { DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_KERNEL, DRUPAL_BOOTSTRAP_PAGE_CACHE, - DRUPAL_BOOTSTRAP_VARIABLES, DRUPAL_BOOTSTRAP_CODE, DRUPAL_BOOTSTRAP_FULL, ); @@ -1802,10 +1677,6 @@ function drupal_bootstrap($phase = NULL, $new_phase = TRUE) { _drupal_bootstrap_page_cache(); break; - case DRUPAL_BOOTSTRAP_VARIABLES: - _drupal_bootstrap_variables(); - break; - case DRUPAL_BOOTSTRAP_CODE: require_once __DIR__ . '/common.inc'; _drupal_bootstrap_code(); @@ -2010,7 +1881,6 @@ function _drupal_bootstrap_page_cache() { $cache_enabled = TRUE; } else { - drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE); $config = \Drupal::config('system.performance'); $cache_enabled = $config->get('cache.page.use_internal'); } @@ -2079,16 +1949,6 @@ function _drupal_initialize_db_test_prefix() { } /** - * Loads system variables and all enabled bootstrap modules. - */ -function _drupal_bootstrap_variables() { - global $conf; - - // Load variables from the database, but do not overwrite variables set in settings.php. - $conf = variable_initialize(isset($conf) ? $conf : array()); -} - -/** * Returns the current bootstrap phase for this Drupal process. * * The current phase is the one most recently completed by drupal_bootstrap(). diff --git a/core/includes/language.inc b/core/includes/language.inc index 618e3a7..60c6490 100644 --- a/core/includes/language.inc +++ b/core/includes/language.inc @@ -476,7 +476,6 @@ function language_negotiation_method_invoke($method_id, $method = NULL, $request $cache_enabled = TRUE; } else { - drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE); $config = \Drupal::config('system.performance'); $cache_enabled = $config->get('cache.page.use_internal'); } diff --git a/core/includes/update.inc b/core/includes/update.inc index b17624f..d4f719e 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -119,6 +119,8 @@ function update_prepare_d8_bootstrap() { // Do not attempt to dump and write it. $kernel = new DrupalKernel('update', drupal_classloader(), FALSE); $kernel->boot(); + $request = Request::createFromGlobals(); + \Drupal::getContainer()->set('request', $request); // If any of the required settings needs to be written, then settings.php // needs to be writable. @@ -315,9 +317,8 @@ function update_prepare_d8_bootstrap() { update_add_cache_columns($table); } - // Bootstrap variables so we can update theme while preparing the update - // process. - drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); + // Bootstrap to cache system. + drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE); // Update the 'language_default' system variable, if configured. // Required to run before drupal_install_config_directories(), since that @@ -458,6 +459,7 @@ function update_prepare_d8_bootstrap() { new Settings($settings); $kernel = new DrupalKernel('update', drupal_classloader(), FALSE); $kernel->boot(); + \Drupal::getContainer()->set('request', $request); // Clear the D7 caches, to ensure that for example the theme_registry does not // take part in the upgrade process. @@ -1331,7 +1333,7 @@ function update_retrieve_dependencies() { /** * Gets the value of a variable from the database during 7.x-8.x upgrades. * - * Use this during the 7.x-8.x upgrade path instead of variable_get(). + * Use this during the 7.x-8.x upgrade path. * * @param string $name * The name of the variable. @@ -1356,7 +1358,7 @@ function update_variable_get($name, $default = NULL) { /** * Sets a persistent variable during the 7.x-8.x upgrade path. * - * Use this during the 7.x-8.x upgrade path instead of variable_set(). + * Use this during the 7.x-8.x upgrade path. * * @param string $name * The name of the variable to set. @@ -1382,7 +1384,7 @@ function update_variable_set($name, $value) { /** * Delete a variable from the database during the 7.x-8.x upgrade path. * - * Use this during the 7.x-8.x upgrade path instead of variable_del(). + * Use this during the 7.x-8.x upgrade path. * * @param string $name * The name of the variable to delete. @@ -1447,8 +1449,8 @@ function update_variables_to_config($config_name, array $variable_map) { foreach ($variable_map as $variable_name => $config_key) { // This function migrates variables regardless of their value, including // NULL values. Any possibly required customizations need to be performed - // manually, either via variable_set() before calling this function or via - // \Drupal::config() after calling this function. + // manually, either via update_variable_set() before calling this function + // or via \Drupal::config() after calling this function. if (isset($variables[$variable_name])) { $value = unserialize($variables[$variable_name]); $config->set($config_key, $value); diff --git a/core/modules/statistics/statistics.php b/core/modules/statistics/statistics.php index ed132e8..59675f1 100644 --- a/core/modules/statistics/statistics.php +++ b/core/modules/statistics/statistics.php @@ -11,7 +11,7 @@ // Load the Drupal bootstrap. require_once dirname(dirname(__DIR__)) . '/vendor/autoload.php'; require_once dirname(dirname(__DIR__)) . '/includes/bootstrap.inc'; -drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); +drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE); if (\Drupal::config('statistics.settings')->get('count_content_views')) { $nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT); diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php deleted file mode 100644 index 9729ea3..0000000 --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php +++ /dev/null @@ -1,63 +0,0 @@ - 'Variable test', - 'description' => 'Make sure the variable system functions correctly.', - 'group' => 'Bootstrap' - ); - } - - /** - * Tests variables then deletes them. - */ - function testVariable() { - // Setting and retrieving values. - $variable = $this->randomName(); - variable_set('simpletest_bootstrap_variable_test', $variable); - $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), 'Setting and retrieving values'); - - // Make sure the variable persists across multiple requests. - $this->drupalGet('system-test/variable-get'); - $this->assertText($variable, 'Variable persists across multiple requests'); - - // Deleting variables. - $default_value = $this->randomName(); - variable_del('simpletest_bootstrap_variable_test'); - $variable = variable_get('simpletest_bootstrap_variable_test', $default_value); - $this->assertIdentical($variable, $default_value, 'Deleting variables'); - } - - /** - * Makes sure that the default variable parameter is passed through okay. - */ - function testVariableDefaults() { - // Tests passing nothing through to the default. - $this->assertIdentical(NULL, variable_get('simpletest_bootstrap_variable_test'), 'Variables are correctly defaulting to NULL.'); - - // Tests passing 5 to the default parameter. - $this->assertIdentical(5, variable_get('simpletest_bootstrap_variable_test', 5), 'The default variable parameter is passed through correctly.'); - } - -} diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 3af30c8..ec9d635 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -208,7 +208,7 @@ function system_theme_default() { // Rebuild the menu. This duplicates the menu_router_rebuild() in // theme_enable(). However, modules must know the current default theme in // order to use this information in hook_menu() or hook_menu_alter() - // implementations, and doing the variable_set() before the theme_enable() + // implementations, and saving the config before the theme_enable() // could result in a race condition where the theme is default but not // enabled. \Drupal::service('router.builder')->rebuild(); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 34d8dde..57f50eb 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -576,29 +576,6 @@ function system_install() { * Implements hook_schema(). */ function system_schema() { - // NOTE: {variable} needs to be created before all other tables, as - // some database drivers, e.g. Oracle and DB2, will require variable_get() - // and variable_set() for overcoming some database specific limitations. - $schema['variable'] = array( - 'description' => 'Named variable/value pairs created by Drupal core or any other module or theme. All variables are cached in memory at the start of every Drupal request so developers should not be careless about what is stored here.', - 'fields' => array( - 'name' => array( - 'description' => 'The name of the variable.', - 'type' => 'varchar', - 'length' => 128, - 'not null' => TRUE, - 'default' => '', - ), - 'value' => array( - 'description' => 'The value of the variable.', - 'type' => 'blob', - 'not null' => TRUE, - 'size' => 'big', - ), - ), - 'primary key' => array('name'), - ); - $schema['batch'] = array( 'description' => 'Stores details about batches (processes that run in multiple HTTP requests).', 'fields' => array( diff --git a/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php index 058aabe..5d7f49c 100644 --- a/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php @@ -57,13 +57,6 @@ public function authorizeInit($page_title) { } /** - * @todo Remove as part of https://drupal.org/node/1775842. - */ - public function variableGet() { - return variable_get('simpletest_bootstrap_variable_test'); - } - - /** * @todo Remove system_test_set_header(). */ public function setHeader() { diff --git a/core/modules/system/tests/modules/system_test/system_test.routing.yml b/core/modules/system/tests/modules/system_test/system_test.routing.yml index 660cfce..ecd03ed 100644 --- a/core/modules/system/tests/modules/system_test/system_test.routing.yml +++ b/core/modules/system/tests/modules/system_test/system_test.routing.yml @@ -59,14 +59,6 @@ system_test.authorize_init: requirements: _permission: 'administer software updates' -system_test.variable_get: - path: '/system-test/variable-get' - defaults: - _title: 'Variable Get' - _content: '\Drupal\system_test\Controller\SystemTestController::variableGet' - requirements: - _permission: 'access content' - system_test.set_header: path: '/system-test/set-header' defaults: diff --git a/core/modules/update/update.install b/core/modules/update/update.install index 505b1ca..5e73f4d 100644 --- a/core/modules/update/update.install +++ b/core/modules/update/update.install @@ -68,10 +68,6 @@ function update_install() { * Implements hook_uninstall(). */ function update_uninstall() { - // @todo D8: Convert to new state storage. - variable_del('update_last_check'); - variable_del('update_last_email_notification'); - $queue = \Drupal::queue('update_fetch_tasks'); $queue->deleteQueue(); } diff --git a/core/update.php b/core/update.php index 527a703..7097df2 100644 --- a/core/update.php +++ b/core/update.php @@ -347,11 +347,8 @@ function update_check_requirements($skip_warnings = FALSE) { update_prepare_d8_bootstrap(); // Determine if the current user has access to run update.php. -drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); - -// A request object from the HTTPFoundation to tell us about the request. -$request = Request::createFromGlobals(); -\Drupal::getContainer()->set('request', $request); +drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE); +$request = \Drupal::request(); require_once DRUPAL_ROOT . '/' . settings()->get('session_inc', 'core/includes/session.inc'); drupal_session_initialize();