diff options
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.admin.inc | 27 | ||||
-rw-r--r-- | modules/system/system.install | 7 | ||||
-rw-r--r-- | modules/system/system.module | 26 | ||||
-rw-r--r-- | modules/system/system.test | 67 |
4 files changed, 88 insertions, 39 deletions
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index cafe079bd..868bd4315 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -1168,6 +1168,7 @@ function system_modules_submit($form, &$form_state) { if ($module['enabled']) { if (drupal_get_installed_schema_version($name) == SCHEMA_UNINSTALLED) { $actions['install'][] = $name; + $actions['enable'][] = $name; } elseif (!module_exists($name)) { $actions['enable'][] = $name; @@ -1183,37 +1184,27 @@ function system_modules_submit($form, &$form_state) { $pre_install_list = module_list(); unset($form_state['storage']); + // Reverse the 'enable' list, to order dependencies before dependents. + rsort($actions['enable']); + // Installs, enables, and disables modules. - module_enable($actions['enable']); - module_disable($actions['disable']); - module_enable($actions['install']); + module_enable($actions['enable'], FALSE); + module_disable($actions['disable'], FALSE); - // Gets module list after install process, displays message if there are changes. + // Gets module list after install process, flushes caches and displays a + // message if there are changes. $post_install_list = module_list(TRUE); if ($pre_install_list != $post_install_list) { + drupal_flush_all_caches(); drupal_set_message(t('The configuration options have been saved.')); } - // Clear all caches. - registry_rebuild(); - system_rebuild_theme_data(); - drupal_theme_rebuild(); - node_types_rebuild(); - menu_rebuild(); - cache_clear_all('schema', 'cache'); - entity_info_cache_clear(); - drupal_clear_css_cache(); - drupal_clear_js_cache(); - $form_state['redirect'] = 'admin/modules'; // Notify locale module about module changes, so translations can be // imported. This might start a batch, and only return to the redirect // path after that. module_invoke('locale', 'system_update', $actions['install']); - - // Synchronize to catch any actions that were added or removed. - actions_synchronize(); } /** diff --git a/modules/system/system.install b/modules/system/system.install index fc6ff52a9..4caeaa94e 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -2246,13 +2246,6 @@ function system_update_7036() { } /** - * Rename action description to label. - */ -function system_update_7037() { - db_change_field('actions', 'description', 'label', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0')); -} - -/** * Upgrade the {url_alias} table and create a cache bin for path aliases. */ function system_update_7042() { diff --git a/modules/system/system.module b/modules/system/system.module index ce555c927..815383bcb 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2601,23 +2601,21 @@ function system_find_base_themes($themes, $key, $used_keys = array()) { * An array of regions in the form $region['name'] = 'description'. */ function system_region_list($theme_key, $show = REGIONS_ALL) { - $list = &drupal_static(__FUNCTION__, array()); + $themes = list_themes(); + if (!isset($themes[$theme_key])) { + return array(); + } - if (empty($list[$theme_key][$show])) { - $themes = list_themes(); - if (!isset($themes[$theme_key])) { - $list[$theme_key][$show] = array(); - return $list[$theme_key][$show]; - } - $info = $themes[$theme_key]->info; - // If requested, suppress hidden regions. See block_admin_display_form(). - foreach ($info['regions'] as $name => $label) { - if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) { - $list[$theme_key][$show][$name] = $label; - } + $list = array(); + $info = $themes[$theme_key]->info; + // If requested, suppress hidden regions. See block_admin_display_form(). + foreach ($info['regions'] as $name => $label) { + if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) { + $list[$name] = $label; } } - return $list[$theme_key][$show]; + + return $list; } /** diff --git a/modules/system/system.test b/modules/system/system.test index 3946199ec..44768352d 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -1667,6 +1667,73 @@ array_space[a b] = Value'; } /** + * Tests the effectiveness of hook_system_info_alter(). + */ +class SystemInfoAlterTestCase extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'System info alter', + 'description' => 'Tests the effectiveness of hook_system_info_alter().', + 'group' => 'System', + ); + } + + /** + * Tests that {system}.info is rebuilt after a module that implements + * hook_system_info_alter() is enabled. Also tests if core *_list() functions + * return freshly altered info. + */ + function testSystemInfoAlter() { + // Enable our test module. Flush all caches, which we assert is the only + // thing necessary to use the rebuilt {system}.info. + module_enable(array('module_test'), FALSE); + drupal_flush_all_caches(); + $this->assertTrue(module_exists('module_test'), t('Test module is enabled.')); + + $info = $this->getSystemInfo('seven', 'theme'); + $this->assertTrue(isset($info['regions']['test_region']), t('Altered theme info was added to {system}.info.')); + $seven_regions = system_region_list('seven'); + $this->assertTrue(isset($seven_regions['test_region']), t('Altered theme info was returned by system_region_list().')); + $system_list_themes = system_list('theme'); + $info = $system_list_themes['seven']->info; + $this->assertTrue(isset($info['regions']['test_region']), t('Altered theme info was returned by system_list().')); + $list_themes = list_themes(); + $this->assertTrue(isset($list_themes['seven']->info['regions']['test_region']), t('Altered theme info was returned by list_themes().')); + + // Disable the module and verify that {system}.info is rebuilt without it. + module_disable(array('module_test'), FALSE); + drupal_flush_all_caches(); + $this->assertFalse(module_exists('module_test'), t('Test module is disabled.')); + + $info = $this->getSystemInfo('seven', 'theme'); + $this->assertFalse(isset($info['regions']['test_region']), t('Altered theme info was removed from {system}.info.')); + $seven_regions = system_region_list('seven'); + $this->assertFalse(isset($seven_regions['test_region']), t('Altered theme info was not returned by system_region_list().')); + $system_list_themes = system_list('theme'); + $info = $system_list_themes['seven']->info; + $this->assertFalse(isset($info['regions']['test_region']), t('Altered theme info was not returned by system_list().')); + $list_themes = list_themes(); + $this->assertFalse(isset($list_themes['seven']->info['regions']['test_region']), t('Altered theme info was not returned by list_themes().')); + } + + /** + * Returns the info array as it is stored in {system}. + * + * @param $name + * The name of the record in {system}. + * @param $type + * The type of record in {system}. + * + * @return + * Array of info, or FALSE if the record is not found. + */ + function getSystemInfo($name, $type) { + $raw_info = db_query("SELECT info FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField(); + return $raw_info ? unserialize($raw_info) : FALSE; + } +} + +/** * Tests for the update system functionality. */ class UpdateScriptFunctionalTest extends DrupalWebTestCase { |