@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+29 -15
+29 -15
src/applications/paste/query/PhabricatorPasteQuery.php
··· 55 55 56 56 $pastes = $table->loadAllFromArray($data); 57 57 58 - if ($pastes && $this->needRawContent) { 59 - $this->loadRawContent($pastes); 58 + return $pastes; 59 + } 60 + 61 + protected function willFilterPage(array $pastes) { 62 + if (!$pastes) { 63 + return $pastes; 60 64 } 61 65 62 - if ($pastes && $this->needContent) { 63 - $this->loadContent($pastes); 66 + if ($this->needRawContent) { 67 + $pastes = $this->loadRawContent($pastes); 68 + } 69 + 70 + if ($this->needContent) { 71 + $pastes = $this->loadContent($pastes); 64 72 } 65 73 66 74 return $pastes; ··· 113 121 $file_phids); 114 122 $files = mpull($files, null, 'getPHID'); 115 123 116 - foreach ($pastes as $paste) { 124 + foreach ($pastes as $key => $paste) { 117 125 $file = idx($files, $paste->getFilePHID()); 118 - if ($file) { 119 - $paste->attachRawContent($file->loadFileData()); 120 - } else { 121 - $paste->attachRawContent(''); 126 + if (!$file) { 127 + unset($pastes[$key]); 128 + continue; 122 129 } 130 + $paste->attachRawContent($file->loadFileData()); 123 131 } 132 + 133 + return $pastes; 124 134 } 125 135 126 136 private function loadContent(array $pastes) { ··· 134 144 $keys[] = $this->getContentCacheKey($paste); 135 145 } 136 146 137 - 138 147 $caches = $cache->getKeys($keys); 148 + $results = array(); 139 149 140 150 $need_raw = array(); 141 - foreach ($pastes as $paste) { 151 + foreach ($pastes as $key => $paste) { 142 152 $key = $this->getContentCacheKey($paste); 143 153 if (isset($caches[$key])) { 144 154 $paste->attachContent(phutil_safe_html($caches[$key])); 155 + $results[$key] = $paste; 145 156 } else { 146 - $need_raw[] = $paste; 157 + $need_raw[$key] = $paste; 147 158 } 148 159 } 149 160 150 161 if (!$need_raw) { 151 - return; 162 + return $results; 152 163 } 153 164 154 165 $write_data = array(); 155 166 156 - $this->loadRawContent($need_raw); 157 - foreach ($need_raw as $paste) { 167 + $need_raw = $this->loadRawContent($need_raw); 168 + foreach ($need_raw as $key => $paste) { 158 169 $content = $this->buildContent($paste); 159 170 $paste->attachContent($content); 160 171 161 172 $write_data[$this->getContentCacheKey($paste)] = (string)$content; 173 + $results[$key] = $paste; 162 174 } 163 175 164 176 $cache->setKeys($write_data); 177 + 178 + return $results; 165 179 } 166 180 167 181