From b3b6021b0a70979a1084111ae43c1170a7592b37 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 6 Sep 2010 12:41:27 -0700 Subject: Don't bomb on the race condition when we're trying to create the gallery/_cache row and it already exists. Fixes ticket #1338. --- modules/gallery/helpers/module.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers/module.php') diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index ca6651f1..736b6854 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -448,7 +448,17 @@ class module_Core { $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; + } + } } } -- cgit v1.2.3