Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.245 diff -u -r1.245 block.module --- modules/block/block.module 18 Dec 2006 21:49:39 -0000 1.245 +++ modules/block/block.module 30 Dec 2006 15:36:17 -0000 @@ -710,3 +710,16 @@ } return $blocks[$region]; } + +/** + * Implementation of hook_system_notify() + * + * Ensure that blocks are in place for themes being enabled. + */ +function block_system_notify($type, $disabled, $enabled, $new = array()) { + if ($type == 'theme') { + foreach($enabled as $theme) { + system_initialize_theme_blocks($theme); + } + } +} Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.433 diff -u -r1.433 system.module --- modules/system/system.module 27 Dec 2006 21:59:32 -0000 1.433 +++ modules/system/system.module 30 Dec 2006 15:36:19 -0000 @@ -1188,6 +1188,13 @@ function system_themes_submit($form_id, $form_values) { + // Store list of previously enabled themes and disable all themes + $wasenabled = $isenabled = array(); + foreach (list_themes() as $theme) { + if ($theme->status) { + $wasenabled[] = $theme->name; + } + } db_query("UPDATE {system} SET status = 0 WHERE type = 'theme'"); if ($form_values['op'] == t('Save configuration')) { @@ -1195,10 +1202,7 @@ foreach ($form_values['status'] as $key => $choice) { // Always enable the default theme, despite its status checkbox being checked: if ($choice || $form_values['theme_default'] == $key) { - // If theme status is being set to 1 from 0, initialize block data for this theme if necessary. - if (db_num_rows(db_query("SELECT status FROM {system} WHERE type = 'theme' AND name = '%s' AND status = 0", $key))) { - system_initialize_theme_blocks($key); - } + $isenabled[] = $key; db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $key); } } @@ -1215,8 +1219,12 @@ else { variable_del('theme_default'); db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' AND name = 'garland'"); + $isenabled = array('garland'); } + // Notify interested parties about theme related changes + module_invoke_all('system_notify', 'theme', array_diff($wasenabled, $isenabled), array_diff($isenabled, $wasenabled)); + menu_rebuild(); drupal_set_message(t('The configuration options have been saved.')); return 'admin/build/themes'; @@ -1474,6 +1482,8 @@ } } + $old_module_list = module_list(); + if (!empty($enable_modules)) { module_enable($enable_modules); } @@ -1481,8 +1491,6 @@ module_disable($disable_modules); } - $old_module_list = module_list(); - // Install new modules. foreach ($new_modules as $key => $module) { if (!drupal_check_module($module)) { @@ -1490,6 +1498,10 @@ } } drupal_install_modules($new_modules); + + // Notify interested parties about module related changes + $oldmodules = array_keys($old_module_list); + module_invoke_all('system_notify', 'module', array_diff($oldmodules, $enable_modules), array_diff($enable_modules, $oldmodules), $new_modules); $current_module_list = module_list(TRUE, FALSE);