From 36b3501e18a37a759127b0d61078098de973dcba Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Fri, 13 May 2011 15:32:13 -0400 Subject: [PATCH] - Patch #690544 by bleen18, andypost, marcvangend, dbeheydt, rschwab, robertom: blocks admin (admin/structure/block) requires menu_rebuild() to display settings for current theme. --- modules/system/system.admin.inc | 8 ++++++++ modules/system/system.test | 22 +++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 92c534e338d0..9e7d69dd3aed 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -349,6 +349,14 @@ function system_theme_default() { } // Set the default theme. variable_set('theme_default', $theme); + + // Rebuild the menu. This duplicates the menu_rebuild() in theme_enable(). + // However, modules must know the current default theme in order to use + // this information in hook_menu() or hook_menu_alter() implementations, + // and doing the variable_set() before the theme_enable() could result + // in a race condition where the theme is default but not enabled. + menu_rebuild(); + // The status message depends on whether an admin theme is currently in use: // a value of 0 means the admin theme is set to be the default theme. $admin_theme = variable_get('admin_theme', 0); diff --git a/modules/system/system.test b/modules/system/system.test index 402fecc45794..3ce5177eb2b6 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -1359,7 +1359,7 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase { function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access')); + $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks')); $this->drupalLogin($this->admin_user); $this->node = $this->drupalCreateNode(); } @@ -1443,6 +1443,26 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase { $this->drupalGet('node/add'); $this->assertRaw('themes/bartik', t('Site default theme used on the add content page.')); } + + /** + * Test switching the default theme. + */ + function testSwitchDefaultTheme() { + // Enable "stark" and set it as the default theme. + theme_enable(array('stark')); + $this->drupalGet('admin/appearance'); + $this->clickLink(t('Set default'), 1); + $this->assertTrue(variable_get('theme_default', '') == 'stark', t('Site default theme switched successfully.')); + + // Test the default theme on the secondary links (blocks admin page). + $this->drupalGet('admin/structure/block'); + $this->assertText('Stark(' . t('active tab') . ')', t('Default local task on blocks admin page is the default theme.')); + // Switch back to Bartik and test again to test that the menu cache is cleared. + $this->drupalGet('admin/appearance'); + $this->clickLink(t('Set default'), 0); + $this->drupalGet('admin/structure/block'); + $this->assertText('Bartik(' . t('active tab') . ')', t('Default local task on blocks admin page has changed.')); + } } -- GitLab