diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 7d638f6..e8d704c 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -60,8 +60,7 @@ function drupal_theme_access($theme) { * @see drupal_theme_access() */ function _drupal_theme_access($theme) { - $admin_theme = variable_get('admin_theme'); - return !empty($theme->status) || ($admin_theme && $theme->name == $admin_theme); + return !empty($theme->status); } /** diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 97f59e9..b0ee304 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -177,7 +177,7 @@ function block_menu() { } /** - * Access callback: Only admin or enabled themes can be accessed. + * Access callback: Only enabled themes can be accessed. * * Path: * - admin/structure/block/list/% (for each theme) diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php deleted file mode 100644 index 0397802..0000000 --- a/core/modules/block/lib/Drupal/block/Tests/BlockAdminThemeTest.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Admin theme block admin accessibility', - 'description' => "Check whether the block administer page for a disabled theme accessible if and only if it's the admin theme.", - 'group' => 'Block', - ); - } - - function setUp() { - parent::setUp(array('block')); - } - - /** - * Check for the accessibility of the admin theme on the block admin page. - */ - function testAdminTheme() { - // Create administrative user. - $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); - $this->drupalLogin($admin_user); - - // Ensure that access to block admin page is denied when theme is disabled. - $this->drupalGet('admin/structure/block/list/bartik'); - $this->assertResponse(403, t('The block admin page for a disabled theme can not be accessed')); - - // Enable admin theme and confirm that tab is accessible. - $edit['admin_theme'] = 'bartik'; - $this->drupalPost('admin/appearance', $edit, t('Save configuration')); - $this->drupalGet('admin/structure/block/list/bartik'); - $this->assertResponse(200, t('The block admin page for the admin theme can be accessed')); - } -} diff --git a/core/modules/block/lib/Drupal/block/Tests/DisabledBlockAdminTest.php b/core/modules/block/lib/Drupal/block/Tests/DisabledBlockAdminTest.php new file mode 100644 index 0000000..3ab8f33 --- /dev/null +++ b/core/modules/block/lib/Drupal/block/Tests/DisabledBlockAdminTest.php @@ -0,0 +1,40 @@ + 'Disabled theme admin', + 'description' => "Check the administer page for disabled theme.", + 'group' => 'Block', + ); + } + + function setUp() { + parent::setUp(array('block')); + } + + /** + * Check for the accessibility of the admin theme on the block admin page. + */ + function testAdminTheme() { + // Create administrative user. + $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); + $this->drupalLogin($admin_user); + + // Ensure that access to block admin page is denied when theme is disabled. + $this->drupalGet('admin/structure/block/list/bartik'); + $this->assertResponse(403, t('The block admin page for a disabled theme can not be accessed.')); + } +} diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index a31e278..da0444a 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -117,12 +117,12 @@ function system_themes_page() { $theme_default = variable_get('theme_default', 'stark'); $theme_groups = array(); + $admin_theme = variable_get('admin_theme', 0); foreach ($themes as &$theme) { if (!empty($theme->info['hidden'])) { continue; } - $admin_theme_options[$theme->name] = $theme->info['name']; $theme->is_default = ($theme->name == $theme_default); // Identify theme screenshot. @@ -169,12 +169,14 @@ function system_themes_page() { } if (!empty($theme->status)) { if (!$theme->is_default) { - $theme->operations[] = array( - 'title' => t('Disable'), - 'href' => 'admin/appearance/disable', - 'query' => $query, - 'attributes' => array('title' => t('Disable !theme theme', array('!theme' => $theme->info['name']))), - ); + if ($theme->name != $admin_theme) { + $theme->operations[] = array( + 'title' => t('Disable'), + 'href' => 'admin/appearance/disable', + 'query' => $query, + 'attributes' => array('title' => t('Disable !theme theme', array('!theme' => $theme->info['name']))), + ); + } $theme->operations[] = array( 'title' => t('Set default'), 'href' => 'admin/appearance/default', @@ -182,6 +184,7 @@ function system_themes_page() { 'attributes' => array('title' => t('Set !theme as default theme', array('!theme' => $theme->info['name']))), ); } + $admin_theme_options[$theme->name] = $theme->info['name']; } else { $theme->operations[] = array( @@ -206,6 +209,9 @@ function system_themes_page() { $theme->classes[] = 'theme-default'; $theme->notes[] = t('default theme'); } + if ($theme->name == $admin_theme || ($theme->is_default && $admin_theme == '0')) { + $theme->notes[] = t('admin theme'); + } // Sort enabled and disabled themes into their own groups. $theme_groups[$theme->status ? 'enabled' : 'disabled'][] = $theme; @@ -294,7 +300,7 @@ function system_theme_disable() { // Check if the specified theme is one recognized by the system. if (!empty($themes[$theme])) { - if ($theme == variable_get('theme_default', 'stark')) { + if ($theme == variable_get('theme_default', 'stark') || $theme == variable_get('admin_theme', 0)) { // Don't disable the default theme. drupal_set_message(t('%theme is the default theme and cannot be disabled.', array('%theme' => $themes[$theme]->info['name'])), 'error'); } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 5394830..bcc44d1 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1779,7 +1779,7 @@ function blocked_ip_load($iid) { } /** - * Menu item access callback - only admin or enabled themes can be accessed. + * Menu item access callback - only enabled themes can be accessed. */ function _system_themes_access($theme) { return user_access('administer themes') && drupal_theme_access($theme); diff --git a/core/modules/system/system.test b/core/modules/system/system.test index 9d25130..a44423b 100644 --- a/core/modules/system/system.test +++ b/core/modules/system/system.test @@ -1870,6 +1870,9 @@ class SystemThemeFunctionalTest extends WebTestBase { function testAdministrationTheme() { theme_enable(array('stark')); variable_set('theme_default', 'stark'); + + // Make seven available as a theme option. + theme_enable(array('seven')); // Enable an administration theme and show it on the node admin pages. $edit = array( 'admin_theme' => 'seven', diff --git a/core/modules/system/tests/batch.test b/core/modules/system/tests/batch.test index e39bcf5..77aeae5 100644 --- a/core/modules/system/tests/batch.test +++ b/core/modules/system/tests/batch.test @@ -301,6 +301,7 @@ class BatchPageTestCase extends WebTestBase { // Make sure that the page which starts the batch (an administrative page) // is using a different theme than would normally be used by the batch API. variable_set('theme_default', 'bartik'); + theme_enable(array('seven')); variable_set('admin_theme', 'seven'); // Log in as an administrator who can see the administrative theme. $admin_user = $this->drupalCreateUser(array('view the administration theme')); diff --git a/core/modules/system/tests/menu.test b/core/modules/system/tests/menu.test index dbd94a1..bf6fdd3 100644 --- a/core/modules/system/tests/menu.test +++ b/core/modules/system/tests/menu.test @@ -187,6 +187,7 @@ class MenuRouterTestCase extends WebTestBase { * Test the theme callback when it is set to use an administrative theme. */ function testThemeCallbackAdministrative() { + theme_enable(array('seven')); $this->drupalGet('menu-test/theme-callback/use-admin-theme'); $this->assertText('Custom theme: seven. Actual theme: seven.', t('The administrative theme can be correctly set in a theme callback.')); $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page.")); @@ -196,6 +197,7 @@ class MenuRouterTestCase extends WebTestBase { * Test that the theme callback is properly inherited. */ function testThemeCallbackInheritance() { + theme_enable(array('seven')); $this->drupalGet('menu-test/theme-callback/use-admin-theme/inheritance'); $this->assertText('Custom theme: seven. Actual theme: seven. Theme callback inheritance is being tested.', t('Theme callback inheritance correctly uses the administrative theme.')); $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page.")); @@ -226,6 +228,7 @@ class MenuRouterTestCase extends WebTestBase { */ function testThemeCallbackMaintenanceMode() { variable_set('maintenance_mode', TRUE); + theme_enable(array('seven')); // For a regular user, the fact that the site is in maintenance mode means // we expect the theme callback system to be bypassed entirely. @@ -330,6 +333,7 @@ class MenuRouterTestCase extends WebTestBase { // the requested page. variable_set('menu_test_hook_custom_theme_name', 'stark'); theme_enable(array('stark')); + theme_enable(array('seven')); // The menu "theme callback" should take precedence over a value set in // hook_custom_theme(). diff --git a/core/modules/taxonomy/taxonomy.test b/core/modules/taxonomy/taxonomy.test index c7e87e8..c44083f 100644 --- a/core/modules/taxonomy/taxonomy.test +++ b/core/modules/taxonomy/taxonomy.test @@ -1901,6 +1901,7 @@ class TaxonomyThemeTestCase extends TaxonomyWebTestCase { function testTaxonomyTermThemes() { // Adding a term to a vocabulary is considered an administrative action and // should use the administrative theme. + theme_enable(array('seven')); $vocabulary = $this->createVocabulary(); $this->drupalGet('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add'); $this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page for adding a taxonomy term."));