From 41814bb38c67f86c7ad285eb28bcc23c84d36298 Mon Sep 17 00:00:00 2001 From: webchick Date: Thu, 18 Oct 2012 23:15:53 -0700 Subject: [PATCH] Revert "Issue #1798732 by Dean Reilly, westie, alexpott, sun: convert install_task() variable to use state system." This reverts commit d3edf50190c543d781f26f649ec248c3c1e59486. This caused unexpected errors with installation on sites with existing settigs.php files. Rolling back until keyvalue store is available during installation. --- core/includes/update.inc | 27 --------- .../Upgrade/StateSystemUpgradePathTest.php | 59 ------------------- core/modules/system/system.install | 16 ++--- .../drupal-7.state.system.database.php | 18 ------ 4 files changed, 9 insertions(+), 111 deletions(-) delete mode 100644 core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php delete mode 100644 core/modules/system/tests/upgrade/drupal-7.state.system.database.php diff --git a/core/includes/update.inc b/core/includes/update.inc index bd13dc71713c..fe8034c22e70 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -1182,33 +1182,6 @@ function update_variables_to_config($config_name, array $variable_map) { db_delete('variable')->condition('name', array_keys($variable_map), 'IN')->execute(); } -/** - * Updates 7.x variables to state records. - * - * Provides a generalized method to migrate variables from 7.x to 8.x's - * state() system. - * - * @param array $variable_map - * An associative array that maps old variables names to new state record - * names; e.g.: - * @code - * array('old_variable' => 'extension.new_name') - * @endcode - * This would migrate the value contained in variable name 'old_variable' into - * the state item 'extension.new_name'. - * Non-existing variables and variables with NULL values are omitted. - */ -function update_variables_to_state(array $variable_map) { - foreach ($variable_map as $variable_name => $state_name) { - if (NULL !== $value = update_variable_get($variable_name)) { - state()->set($state_name, $value); - } - } - - // Delete the migrated variables. - db_delete('variable')->condition('name', array_keys($variable_map), 'IN')->execute(); -} - /** * Helper function to update entities with uuid. * diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php deleted file mode 100644 index 280faad27cfd..000000000000 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php +++ /dev/null @@ -1,59 +0,0 @@ - 'State system upgrade test', - 'description' => 'Tests upgrade of system variables to the state system.', - 'group' => 'Upgrade path', - ); - } - - public function setUp() { - $this->databaseDumpFiles = array( - drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz', - drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.state.system.database.php', - ); - parent::setUp(); - } - - /** - * Tests upgrade of system variables to state system. - */ - public function testSystemVariableUpgrade() { - $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.'); - - $expected_state = array(); - - $expected_state['system.install_time'] = array( - 'value' => 1304208000, - 'variable_name' => 'install_time', - ); - $expected_state['system.install_task'] = array( - 'value' => 'done', - 'variable_name' => 'install_task', - ); - $expected_state['system.path_alias_whitelist'] = array( - 'value' => array( - - ), - 'variable_name' => 'path_alias_whitelist', - ); - - foreach ($expected_state as $name => $data) { - $this->assertIdentical(state()->get($name), $data['value']); - $deleted = !db_query('SELECT value FROM {variable} WHERE name = :name', array(':name' => $data['variable_name']))->fetchField(); - $this->assertTrue($deleted, format_string('Variable !name has been deleted.', array('!name' => $data['variable_name']))); - } - } -} diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 9026310aed5b..d0deae192171 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2132,15 +2132,17 @@ function system_update_8025() { } /** - * Migrates install_task and install_time variables to State API. - * - * @ingroup config_upgrade + * Convert install_task and install_time variables to state api values. */ function system_update_8026() { - update_variables_to_state(array( - 'install_task' => 'system.install_task', - 'install_time' => 'system.install_time', - )); + $variables = array('system.install_task', 'system.install_time'); + + foreach ($variables as $variable) { + if ($value = update_variable_get($variable, FALSE)) { + state()->set($variable, $value); + } + update_variable_del($variable); + } } /** diff --git a/core/modules/system/tests/upgrade/drupal-7.state.system.database.php b/core/modules/system/tests/upgrade/drupal-7.state.system.database.php deleted file mode 100644 index 54676b96dca2..000000000000 --- a/core/modules/system/tests/upgrade/drupal-7.state.system.database.php +++ /dev/null @@ -1,18 +0,0 @@ -key(array('name' => 'install_time'))->fields(array('value' => serialize(1304208000))) - ->execute(); - -// Add non-default system settings.