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.

Comments

mkalkbrenner’s picture

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.

mkalkbrenner’s picture

Status: Needs work » Postponed

Taxonomy Theme 5.x is unmaintained. As you can see at the project description page we're looking for a co-maintainer espacially for th 5.x version.

mkalkbrenner’s picture

Taxonomy Theme 5.x is unmaintained. As you can see at the project description page we're looking for a co-maintainer espacially for th 5.x version.

mkalkbrenner’s picture

Status: Postponed » Closed (won't fix)

Taxonomy Theme 5.x is unmaintained. Due to the fact that Drupal 5 itself is not maintained anymore, we close this issue to get the issue queue clean for Taxonomy Theme 6.x and 7.x.