Module causes themes to become disabled
| Project: | Taxonomy Theme |
| Version: | 5.x-1.2 |
| Component: | Code / API |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
We run a large website on a multi-tier server environment behind a load balancer. A team of editors use the back-end to manage the site. But over the past few weeks we had errors that where thrown such as:
Duplicate entry 'sites/all/themes/mythemenamehere/style.css' for key 1 query: INSERT INTO system (name, description, type, filename, status, throttle, bootstrap) VALUES ('mythemenamehere', 'sites/all/themes/mythemenamehere/page.tpl.php', 'theme', 'sites/all/themes/mythemenamehere/style.css', 0, 0, 0) in /data/web/een/includes/database.mysql.inc on line 175.
After a lot of code digging I found that the taxonomy_theme module caused this problem. In the method _taxonomy_theme_options() in the taxonomy_theme_admin.inc file the module uses system_theme_data() to get a list of all themes. This is very bad practice because this method does a lot of database queries and updates which cause concurrency problems when used by to many users.
Instead the method list_themes() should be used to get a list of theme names. This is much faster and doesn't have an effect on the Drupal core inner workings.
so:
/**
* function _taxonomy_theme_options().
* (create a list of available themes)
*/
function _taxonomy_theme_options($admin_themes = FALSE, $default = TRUE) {
$themes = system_theme_data();
$options_themes = array();Should become:
/**
* function _taxonomy_theme_options().
* (create a list of available themes)
*/
function _taxonomy_theme_options($admin_themes = FALSE, $default = TRUE) {
$themes = list_themes();
asort($themes);
$options_themes = array();I hope this helps other users in the future.

#1
Thanks for figuring this out. ThemeKey contains the same bug: #617990: Themekey disables themes after configuration
As you might noticed I took over maintenance for Taxonomy Theme: #593984: Is Taxonomy Theme still maintained?
Unfortunately it will take me some more time to know the code well enough to clean up current state in cvs and release a bugfix.