mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
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
This commit is contained in:
parent
3802007082
commit
dd5da0fedb
1 changed files with 9 additions and 9 deletions
|
@ -188,10 +188,14 @@ final class PhabricatorMarkupEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($use_cache) {
|
if ($use_cache) {
|
||||||
|
try {
|
||||||
$blocks = id(new PhabricatorMarkupCache())->loadAllWhere(
|
$blocks = id(new PhabricatorMarkupCache())->loadAllWhere(
|
||||||
'cacheKey IN (%Ls)',
|
'cacheKey IN (%Ls)',
|
||||||
array_keys($use_cache));
|
array_keys($use_cache));
|
||||||
$blocks = mpull($blocks, null, 'getCacheKey');
|
$blocks = mpull($blocks, null, 'getCacheKey');
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
phlog($ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($objects as $key => $info) {
|
foreach ($objects as $key => $info) {
|
||||||
|
@ -220,11 +224,7 @@ final class PhabricatorMarkupEngine {
|
||||||
if (isset($use_cache[$key])) {
|
if (isset($use_cache[$key])) {
|
||||||
// This is just filling a cache and always safe, even on a read pathway.
|
// This is just filling a cache and always safe, even on a read pathway.
|
||||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||||
try {
|
$blocks[$key]->replace();
|
||||||
$blocks[$key]->save();
|
|
||||||
} catch (AphrontQueryDuplicateKeyException $ex) {
|
|
||||||
// Ignore this, we just raced to write the cache.
|
|
||||||
}
|
|
||||||
unset($unguarded);
|
unset($unguarded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue