Users can have disabled themes

matt westgate - January 2, 2004 - 06:41
Project:Drupal
Component:system.module
Category:bug report
Priority:normal
Assigned:matt westgate
Status:closed
Description

If an administrator disables a theme that other users have marked default in their preferences, Drupal still tries to unsuccessfully render the disabled theme for the user.

This patch will set the obsolete user themes back to the default theme so they will always be able to view the site.

AttachmentSize
system.module.patch967 bytes

#1

matt westgate - January 2, 2004 - 06:42

Changing to patch status.

#2

Dries - January 2, 2004 - 10:06

I'd like to discuss the approach taken in this patch. If an administrator disables the theme and reactivates it later, the users' theme settings will be lost. If you look at the code in init_theme() you'll notice that the function does not check anything. To avoid such setting loss, we could easily modify init_theme() not to load themes that are not in the $themes array.

(Speaking of which, I'm not sure why we are constructing and using a $theme object in init_theme() while all we need later on is the theme's name.)

#3

matt westgate - January 2, 2004 - 16:01

Here is an updated patch that does two things:

  1. Remove the theme object. There is no need to keep it around since meta information for a theme can be retrieved via list_themes(). All we really need is the theme name.
  2. Check if the user selected theme is enabled during theme initialization. This is the easiest place to put the check and doesn't mess with the user's settings. Their database profile will still contain the disabled theme selection, but they will be rendering the default admin-selected theme until their chosen theme is once again activated.

Thanks for the guidance on this, Dries.

AttachmentSize
theme.inc.patch 1.59 KB

#4

Dries - January 2, 2004 - 16:25

Committed to HEAD along with some small modifications. Thanks Mathias.

#5

Anonymous - January 16, 2004 - 17:20
 
 

Drupal is a registered trademark of Dries Buytaert.