Skip to content
Permalink
Browse files
Issue #1425868 - Duplicate entry in the system table after upgrade fr…
…om Drupal 6.22 to 6.24.
  • Loading branch information
omega8cc committed Feb 7, 2012
1 parent bf1940b commit 97b8df2795e9565ffff5dcaa00692b8b608ef3ca
Showing 1 changed file with 10 additions and 14 deletions.
@@ -826,25 +826,21 @@ function system_theme_data() {

// If lock not acquired, return $themes data without writing to database.
if ($write_database) {
$names = array();

// Database is locked so no one else can change these settings, we are safe
// to delete everything and write out each of the records.
db_query("DELETE FROM {system} WHERE type = 'theme'");

foreach ($themes as $theme) {
// Record the name of each theme found in the file system.
$names[] = $theme->name;
// Update the contents of the system table.
if (isset($theme->status) && !(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE != 'install')) {
db_query("UPDATE {system} SET owner = '%s', info = '%s', filename = '%s' WHERE name = '%s' AND type = '%s'", $theme->owner, serialize($theme->info), $theme->filename, $theme->name, 'theme');
}
else {
// If status is missing, set it based on this theme name matching the
// configured default theme.
if (!isset($theme->status)) {
$theme->status = ($theme->name == variable_get('theme_default', 'garland'));
// This is a new theme.
db_query("INSERT INTO {system} (name, owner, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, $theme->status, 0, 0);
}
// Insert records back into the system table
db_query("INSERT INTO {system} (name, owner, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, $theme->status, 0, 0);
}
// Delete from the system table any themes missing from the file system.
if ($names) {
db_query("DELETE FROM {system} WHERE type = 'theme' AND name NOT IN (". db_placeholders($names, 'varchar') .")", $names);
}

lock_release('system_theme_data');
}
return $themes;

0 comments on commit 97b8df2

Please sign in to comment.