mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
When a paste's file is deleted, drop it from query results
Summary: We allow files to be deleted from the web UI, including paste files. When a paste's file is deleted, we currently continue to show it in the paste list and then 400 when it's clicked on. Instead, remove it from the list. (Note that it may stick around if it's cached.) Test Plan: Purged general cache, deleted a paste's file, viewed paste list, saw no pastes. Reviewers: dctrwatson, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3265 Differential Revision: https://secure.phabricator.com/D6067
This commit is contained in:
parent
aec0e2f8f9
commit
b91c863780
1 changed files with 29 additions and 15 deletions
|
@ -55,12 +55,20 @@ final class PhabricatorPasteQuery
|
|||
|
||||
$pastes = $table->loadAllFromArray($data);
|
||||
|
||||
if ($pastes && $this->needRawContent) {
|
||||
$this->loadRawContent($pastes);
|
||||
return $pastes;
|
||||
}
|
||||
|
||||
protected function willFilterPage(array $pastes) {
|
||||
if (!$pastes) {
|
||||
return $pastes;
|
||||
}
|
||||
|
||||
if ($pastes && $this->needContent) {
|
||||
$this->loadContent($pastes);
|
||||
if ($this->needRawContent) {
|
||||
$pastes = $this->loadRawContent($pastes);
|
||||
}
|
||||
|
||||
if ($this->needContent) {
|
||||
$pastes = $this->loadContent($pastes);
|
||||
}
|
||||
|
||||
return $pastes;
|
||||
|
@ -113,14 +121,16 @@ final class PhabricatorPasteQuery
|
|||
$file_phids);
|
||||
$files = mpull($files, null, 'getPHID');
|
||||
|
||||
foreach ($pastes as $paste) {
|
||||
foreach ($pastes as $key => $paste) {
|
||||
$file = idx($files, $paste->getFilePHID());
|
||||
if ($file) {
|
||||
$paste->attachRawContent($file->loadFileData());
|
||||
} else {
|
||||
$paste->attachRawContent('');
|
||||
if (!$file) {
|
||||
unset($pastes[$key]);
|
||||
continue;
|
||||
}
|
||||
$paste->attachRawContent($file->loadFileData());
|
||||
}
|
||||
|
||||
return $pastes;
|
||||
}
|
||||
|
||||
private function loadContent(array $pastes) {
|
||||
|
@ -134,34 +144,38 @@ final class PhabricatorPasteQuery
|
|||
$keys[] = $this->getContentCacheKey($paste);
|
||||
}
|
||||
|
||||
|
||||
$caches = $cache->getKeys($keys);
|
||||
$results = array();
|
||||
|
||||
$need_raw = array();
|
||||
foreach ($pastes as $paste) {
|
||||
foreach ($pastes as $key => $paste) {
|
||||
$key = $this->getContentCacheKey($paste);
|
||||
if (isset($caches[$key])) {
|
||||
$paste->attachContent(phutil_safe_html($caches[$key]));
|
||||
$results[$key] = $paste;
|
||||
} else {
|
||||
$need_raw[] = $paste;
|
||||
$need_raw[$key] = $paste;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$need_raw) {
|
||||
return;
|
||||
return $results;
|
||||
}
|
||||
|
||||
$write_data = array();
|
||||
|
||||
$this->loadRawContent($need_raw);
|
||||
foreach ($need_raw as $paste) {
|
||||
$need_raw = $this->loadRawContent($need_raw);
|
||||
foreach ($need_raw as $key => $paste) {
|
||||
$content = $this->buildContent($paste);
|
||||
$paste->attachContent($content);
|
||||
|
||||
$write_data[$this->getContentCacheKey($paste)] = (string)$content;
|
||||
$results[$key] = $paste;
|
||||
}
|
||||
|
||||
$cache->setKeys($write_data);
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue