Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.582 diff -u -p -r1.582 theme.inc --- includes/theme.inc 4 Mar 2010 09:03:08 -0000 1.582 +++ includes/theme.inc 7 Mar 2010 01:24:52 -0000 @@ -1230,16 +1230,20 @@ function theme_render_template($template * An array of theme names. */ function theme_enable($theme_list) { - drupal_clear_css_cache(); - + $result = 0; foreach ($theme_list as $key) { - db_update('system') + $result += db_update('system') ->fields(array('status' => 1)) ->condition('type', 'theme') ->condition('name', $key) ->execute(); } + if (!$result) { + //early return if we didn't actually enable any theme + return FALSE; + } + drupal_clear_css_cache(); list_themes(TRUE); menu_rebuild(); drupal_theme_rebuild(); @@ -1252,7 +1256,7 @@ function theme_enable($theme_list) { // Invoke hook_themes_enabled after the themes have been enabled. module_invoke_all('themes_enabled', $theme_list); - return; + return TRUE; } /** Index: includes/update.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/update.inc,v retrieving revision 1.38 diff -u -p -r1.38 update.inc --- includes/update.inc 25 Feb 2010 09:42:39 -0000 1.38 +++ includes/update.inc 7 Mar 2010 01:24:52 -0000 @@ -37,7 +37,7 @@ function update_check_incompatibility($n // Store values of expensive functions for future use. if (empty($themes) || empty($modules)) { $themes = _system_rebuild_theme_data(); - $modules = system_rebuild_module_data(); + $modules = _system_rebuild_module_data(); } if ($type == 'module' && isset($modules[$name])) { @@ -1216,4 +1216,3 @@ function update_invoke_all() { return $return; } - Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.261 diff -u -p -r1.261 system.admin.inc --- modules/system/system.admin.inc 6 Mar 2010 19:38:34 -0000 1.261 +++ modules/system/system.admin.inc 7 Mar 2010 01:24:54 -0000 @@ -373,8 +373,12 @@ function system_theme_enable() { // Check if the specified theme is one recognized by the system. if (!empty($themes[$theme])) { - theme_enable(array($theme)); - drupal_set_message(t('The %theme theme has been enabled.', array('%theme' => $themes[$theme]->info['name']))); + $result = theme_enable(array($theme)); + if (!$result) { + drupal_set_message(t('%theme could not be enabled.', array('%theme' => $themes[$theme]->info['name']))); + } else { + drupal_set_message(t('The %theme theme has been enabled.', array('%theme' => $themes[$theme]->info['name']))); + } } else { drupal_set_message(t('The %theme theme was not found.', array('%theme' => $theme)), 'error'); @@ -425,7 +429,13 @@ function system_theme_default() { if (!empty($themes[$theme])) { // Enable the theme if it is currently disabled. if (empty($themes[$theme]->status)) { - theme_enable(array($theme)); + $result = theme_enable(array($theme)); + if (!$result) { + //early return if we didn't actually enable a theme + drupal_set_message(t('%theme could not be enabled.', array('%theme' => $themes[$theme]->info['name']))); + drupal_goto('admin/appearance'); + return; + } } // Set the default theme. variable_set('theme_default', $theme); Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.452 diff -u -p -r1.452 system.install --- modules/system/system.install 2 Mar 2010 09:09:45 -0000 1.452 +++ modules/system/system.install 7 Mar 2010 01:24:54 -0000 @@ -336,6 +336,22 @@ function system_requirements($phase) { } } + //See if we have any name conflicts between modules and themes + $requirements['name conflicts'] = array( + 'title' => $t('Name Conflicts'), + 'severity' => REQUIREMENT_OK, + 'value' => $t('No conflicts'), + ); + $themes = array_keys(_system_rebuild_theme_data()); + $modules = array_keys(_system_rebuild_module_data()); + $conflicts = array_intersect($themes, $modules); + if (count($conflicts)) { + $requirements['name conflicts']['severity'] = REQUIREMENT_ERROR; + $requirements['name conflicts']['value'] = $t('Conflicts: '). implode(', ', $conflicts); + $requirements['name conflicts']['description'] = $t('You may not have a module and a theme with the same name.'); + } + + // Verify the update.php access setting if ($phase == 'runtime') { if (!empty($GLOBALS['update_free_access'])) { @@ -1460,6 +1476,9 @@ function system_schema() { ), ), 'primary key' => array('filename'), + 'unique keys' => array( + 'name' => array('name') + ), 'indexes' => array( 'bootstrap' => array('status', 'bootstrap', 'type', 'weight', 'name'), 'system_list' => array('weight', 'name'), @@ -2396,6 +2415,13 @@ function system_update_7050() { } /** + * Make {system}.name unique. + */ +function system_update_7051() { + db_add_unique_key('system', 'name', array('name')); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */ Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.895 diff -u -p -r1.895 system.module --- modules/system/system.module 3 Mar 2010 07:34:25 -0000 1.895 +++ modules/system/system.module 7 Mar 2010 01:24:55 -0000 @@ -2078,7 +2078,11 @@ function system_update_files_database(&$ $file->schema_version = -1; } } - $query->execute(); + try { + $query->execute(); + } catch (Exception $e) { + drupal_set_message($e->getMessage(), 'error'); + } } /**