1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Fix an issue where pastes could be reordered as a side effect of cache fills

Summary: Ref T7803. Pastes which needed a cache fill would incorrectly be dropped to the bottom of the list. Stop doing that.

Test Plan: Loaded a list of pastes with some that needed cache fills, saw them appear in the correct order.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7803

Differential Revision: https://secure.phabricator.com/D12354
This commit is contained in:
epriestley 2015-04-11 18:38:48 -07:00
parent 604d1409f1
commit e6174ed45c

View file

@ -90,7 +90,7 @@ final class PhabricatorPasteQuery
}
if ($this->needContent) {
$pastes = $this->loadContent($pastes);
$this->loadContent($pastes);
}
return $pastes;
@ -203,21 +203,19 @@ final class PhabricatorPasteQuery
}
$caches = $cache->getKeys($keys);
$results = array();
$need_raw = array();
foreach ($pastes as $key => $paste) {
$key = $this->getContentCacheKey($paste);
if (isset($caches[$key])) {
$paste->attachContent(phutil_safe_html($caches[$key]));
$results[$paste->getID()] = $paste;
} else {
$need_raw[$key] = $paste;
}
}
if (!$need_raw) {
return $results;
return;
}
$write_data = array();
@ -226,14 +224,10 @@ final class PhabricatorPasteQuery
foreach ($need_raw as $key => $paste) {
$content = $this->buildContent($paste);
$paste->attachContent($content);
$write_data[$this->getContentCacheKey($paste)] = (string)$content;
$results[$paste->getID()] = $paste;
}
$cache->setKeys($write_data);
return $results;
}
private function buildContent(PhabricatorPaste $paste) {