Skip to content

Commit

Permalink
Don't bomb on the race condition when we're trying to create the
Browse files Browse the repository at this point in the history
gallery/_cache row and it already exists.  Fixes ticket #1338.
  • Loading branch information
bharat committed Sep 6, 2010
1 parent 4a94182 commit b3b6021
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/gallery/helpers/module.php
Expand Up @@ -448,7 +448,17 @@ static function get_var($module_name, $name, $default_value=null) {
$cache->module_name = "gallery";
$cache->name = "_cache";
$cache->value = serialize(self::$var_cache);
$cache->save();
try {
$cache->save();
} catch (Database_Exception $e) {
// There's a potential race condition here. Don't fail if that happens because it's
// bound to be transient and not a huge deal, but at least put something in the logs.
if (stristr($e->getMessage(), "duplicate entry")) {
Kohana_Log::add("error", "Failed to cache vars");
} else {
throw $e;
}
}
}
}

Expand Down

0 comments on commit b3b6021

Please sign in to comment.