Set the admin theme to 'Default theme', then set another theme as default.

You get:

    *  Notice: Undefined index: 0 in system_theme_default() (line 436 of /Users/joachim/Sites/7-drupal/modules/system/system.admin.inc).
    * Notice: Trying to get property of non-object in system_theme_default() (line 436 of /Users/joachim/Sites/7-drupal/modules/system/system.admin.inc).

Status message
Please note that the administration theme is still set to the theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected Bartik theme by default.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aspilicious’s picture

o_O

Cannot reproduce this, I set seven to default, then garland back to default... no notices

joachim’s picture

Status: Active » Needs review
FileSize
1.11 KB

You need to have the 'Admin theme' set to 'Current theme'.

aspilicious’s picture

I find this situation strange

       $admin_theme = variable_get('admin_theme', 0);
-      if ($admin_theme != $theme) {
+      if ($admin_theme && $admin_theme != $theme)

Your patch checks if variable_get('admin_theme', 0); returns a good value...
I don't have any doubts that this is working BUT variable_get('admin_theme', 0); should always return a good value doesn't it?
How can it be that there isn't a admin theme o_O?

joachim’s picture

If the variable is 0 you are then trying to get that key out of the $themes array. There is no 0 key. Hence the error.

aspilicious’s picture

Thats what I mean, how can that variable be 0...
Isn't that plain wrong? Or am I missing something?

joachim’s picture

It'll be 0 if it is not already set in the DB, or if the option 'Default theme' is selected:

  $form['admin_theme']['admin_theme'] = array(
    '#type' => 'select',
    '#options' => array(0 => t('Default theme')) + $theme_options,
    '#title' => t('Administration theme'),
    '#description' => t('Choose "Default theme" to always use the same theme as the rest of the site.'),
    '#default_value' => variable_get('admin_theme', 0),
  );
aspilicious’s picture

Hmmm, I see...

naxoc’s picture

Status: Needs review » Needs work

I tested the patch and it makes the notice go away. Even if the '0' is a little confusing that is in fact what it is set to in the db if the default theme is chosen. Maybe throw in a comment to explain the check for 0?

joachim’s picture

Status: Needs work » Needs review
FileSize
1.31 KB

Ok -- I've made it an explicit check to be not 0, and added a line to explain what the (prior to this patch!) variable_get() is doing for the default value.

naxoc’s picture

Status: Needs review » Needs work

Looks good :) Now the only nitpicky thing I can think of is that there should either be a period after // The status message depends on whether an admin theme is currently in use or the next line of comment should not have a capital first letter.

joachim’s picture

Status: Needs work » Needs review
FileSize
1.31 KB

Thanks for the review!

Added a colon :)

naxoc’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now. And the testbot likes it too :)

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.