=== modified file 'includes/common.inc' --- includes/common.inc 2009-09-30 13:09:29 +0000 +++ includes/common.inc 2009-10-01 01:38:12 +0000 @@ -3922,6 +3922,9 @@ function _drupal_bootstrap_full() { // this before invoking hook_init(), since any modules which initialize the // theme system will prevent a custom theme from being correctly set later. menu_set_custom_theme(); + if (!defined('MAINTENANCE_MODE') && !_menu_site_is_offline()) { + drupal_theme_initialize(); + } // Let all modules take action before menu system handles the request // We do not want this while running update.php. if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') { === modified file 'includes/module.inc' --- includes/module.inc 2009-09-29 18:08:28 +0000 +++ includes/module.inc 2009-09-30 16:26:45 +0000 @@ -346,6 +346,7 @@ function module_hook($module, $hook) { * @see module_implements_write_cache(). */ function module_implements($hook, $sort = FALSE, $reset = FALSE) { + global $theme, $base_theme; $implementations = &drupal_static(__FUNCTION__, array()); // We maintain a persistent cache of hook implementations in addition to the @@ -378,6 +379,12 @@ function module_implements($hook, $sort if (!isset($implementations[$hook])) { $implementations[$hook] = array(); $list = module_list(FALSE, FALSE, $sort); + if ($theme && substr($hook, -6) == '_alter') { + $list[] = $theme; + foreach ($base_theme as $base) { + $list[] = $base->name; + } + } foreach ($list as $module) { if (module_hook($module, $hook)) { $implementations[$hook][$module] = $module; === modified file 'includes/theme.inc' --- includes/theme.inc 2009-09-30 13:09:29 +0000 +++ includes/theme.inc 2009-09-30 15:05:00 +0000 @@ -55,7 +55,7 @@ function drupal_theme_access($theme) { * Initialize the theme system by loading the theme. */ function drupal_theme_initialize() { - global $theme, $user, $theme_key; + global $theme, $user, $theme_key, $base_theme; // If $theme is already set, assume the others are set, too, and do nothing if (isset($theme)) { @@ -84,7 +84,8 @@ function drupal_theme_initialize() { $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme]; $ancestor = $themes[$ancestor]->base_theme; } - _drupal_theme_initialize($themes[$theme], array_reverse($base_theme)); + $base_theme = array_reverse($base_theme); + _drupal_theme_initialize($themes[$theme], $base_theme); } /** === modified file 'includes/theme.maintenance.inc' --- includes/theme.maintenance.inc 2009-09-11 13:56:56 +0000 +++ includes/theme.maintenance.inc 2009-09-30 15:04:32 +0000 @@ -15,7 +15,7 @@ * $conf variable in order to change the maintenance theme. */ function _drupal_maintenance_theme() { - global $theme, $theme_key; + global $theme, $theme_key, $base_theme; // If $theme is already set, assume the others are set too, and do nothing. if (isset($theme)) { @@ -30,6 +30,7 @@ function _drupal_maintenance_theme() { require_once DRUPAL_ROOT . '/includes/module.inc'; require_once DRUPAL_ROOT . '/includes/database/database.inc'; unicode_check(); + $base_theme = array(); // Install and update pages are treated differently to prevent theming overrides. if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) { === modified file 'modules/simpletest/tests/form.test' --- modules/simpletest/tests/form.test 2009-09-29 15:31:12 +0000 +++ modules/simpletest/tests/form.test 2009-09-30 16:00:05 +0000 @@ -363,6 +363,33 @@ class FormsFormCleanIdFunctionalTest ext } /** + * Test hook_form_alter for themes. + */ +class FormsAlterThemeTest extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'hook_form_alter by themes test', + 'description' => 'Test the capability of themes to alter forms.', + 'group' => 'Form API', + ); + } + + function setUp() { + parent::setUp('form_test'); + } + + /** + * Test that the form description we add appears. + */ + function testFormCleanId() { + $this->drupalGet('admin/form_test'); + $this->assertText('Seven form alter'); + } + +} + +/** * Test using drupal_form_submit in a batch. */ class FormAPITestCase extends DrupalWebTestCase { === modified file 'modules/simpletest/tests/form_test.module' --- modules/simpletest/tests/form_test.module 2009-09-18 00:12:45 +0000 +++ modules/simpletest/tests/form_test.module 2009-09-30 16:03:27 +0000 @@ -68,6 +68,14 @@ function form_test_menu() { 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); + + $items['admin/form_test'] = array( + 'title' => 'admin theme form test', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('form_test_test_form'), + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); return $items; } @@ -95,6 +103,13 @@ function form_test_test_form($form, &$fo } /** + * Implement a hook_form_alter in the name of Seven. + */ +function seven_form_form_test_test_form_alter(&$form) { + $form['input']['#description'] = 'Seven form alter'; +} + +/** * Create a header and options array. Helper function for callbacks. */ function _form_test_tableselect_get_data() {