From dd5da0fedba59dcec354b5d5c61125d13da0533d Mon Sep 17 00:00:00 2001 From: vrana Date: Fri, 18 Jan 2013 15:36:41 -0800 Subject: [PATCH] Handle errors in reading cache Summary: I've stored `PhutilSafeHTML` instance to cache on devbox and then wasn't able to read it in production. Test Plan: Displayed revision with unreadable cache, saw error in error log but not fatal. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4520 --- .../markup/PhabricatorMarkupEngine.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php index 0936609c5b..39472a2d73 100644 --- a/src/infrastructure/markup/PhabricatorMarkupEngine.php +++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php @@ -188,10 +188,14 @@ final class PhabricatorMarkupEngine { } if ($use_cache) { - $blocks = id(new PhabricatorMarkupCache())->loadAllWhere( - 'cacheKey IN (%Ls)', - array_keys($use_cache)); - $blocks = mpull($blocks, null, 'getCacheKey'); + try { + $blocks = id(new PhabricatorMarkupCache())->loadAllWhere( + 'cacheKey IN (%Ls)', + array_keys($use_cache)); + $blocks = mpull($blocks, null, 'getCacheKey'); + } catch (Exception $ex) { + phlog($ex); + } } foreach ($objects as $key => $info) { @@ -220,11 +224,7 @@ final class PhabricatorMarkupEngine { if (isset($use_cache[$key])) { // This is just filling a cache and always safe, even on a read pathway. $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); - try { - $blocks[$key]->save(); - } catch (AphrontQueryDuplicateKeyException $ex) { - // Ignore this, we just raced to write the cache. - } + $blocks[$key]->replace(); unset($unguarded); } }