If you look closely at the function definition of theme_get_settings(), you’ll see a not-so-obvious bug.
theme_get_settings() should be returning the values for these settings as they are stored in the database (or as the defaults define them). However, you’ll notice that the returned value for toggle_search
setting is altered depending on the user that is currently viewing the site. That's just wrong!
The check for !module_exists('search') || !user_access('search content')
should be placed where the setting is being used in the business logic; in this case that check should be inside template_preprocess_page because that's where the theme's search box is being added to the page.tpl.php.
If a theme is trying to do something based on the actual value of toggle_search
, the theme will often (but not always) get the wrong value returned by theme_get_settings().
For example, because of this bug, the Zen theme and any theme following the “Initializing the default values” section of the Advanced Theme Settings documentation, will encounter a bizarre error where the search box will get disabled at random times. See #311458: Search box gets disabled after arbitrary amount of time
FYI, the search box feature of themes has been removed from D7, so this is not an issue for D7.
Comment | File | Size | Author |
---|---|---|---|
#2 | theme-get-settings-605768-2.patch | 1.47 KB | JohnAlbin |
Comments
Comment #1
JohnAlbinComment #2
JohnAlbinAnd here's the fix.
Comment #3
q0rban CreditAttribution: q0rban commentedGood catch!
Comment #4
greg.harveyHas anyone checked to see if this is still an issue in D7?
Comment #5
JohnAlbinGreg, the theme's search box feature has been removed in D7. If you want search, you have to enable the search block.
So, that line of code is missing from where it would be in D7's code base. theme_get_settings() has been removed and its code merged with theme_get_setting(). See http://api.drupal.org/api/function/theme_get_setting/7
Comment #6
greg.harveyI see - I didn't read the patch and thought the issue was more generic. Been having similar "forgotten settings" issues with other themes. I bet the cause is the same, though the cure will be subtly different.
Comment #7
JohnAlbinCleaning up my "assigned" queue.
Comment #9
cooldeeponline CreditAttribution: cooldeeponline commentedThanks for the patch.. worked for me!