@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.

Filter pastes at the query level if we're unable to load their content

Summary:
Fixes T8230. I think I broke this in D12354 since I missed the fact that this could filter results, because it's constructed in a sort of weird way. Try to make the logic a little more clear, while retaining the relevant properties:

- Pastes with unloadable content should be discarded;
- the input order should be retained in the result set.

Test Plan: Faked content misses and saw things work instead of fatal.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8230

Differential Revision: https://secure.phabricator.com/D12909

+23 -6
+23 -6
src/applications/paste/query/PhabricatorPasteQuery.php
··· 90 90 } 91 91 92 92 if ($this->needContent) { 93 - $this->loadContent($pastes); 93 + $pastes = $this->loadContent($pastes); 94 94 } 95 95 96 96 return $pastes; ··· 205 205 $caches = $cache->getKeys($keys); 206 206 207 207 $need_raw = array(); 208 - foreach ($pastes as $key => $paste) { 208 + $have_cache = array(); 209 + foreach ($pastes as $paste) { 209 210 $key = $this->getContentCacheKey($paste); 210 211 if (isset($caches[$key])) { 211 212 $paste->attachContent(phutil_safe_html($caches[$key])); 213 + $have_cache[$paste->getPHID()] = true; 212 214 } else { 213 215 $need_raw[$key] = $paste; 214 216 } 215 217 } 216 218 217 219 if (!$need_raw) { 218 - return; 220 + return $pastes; 219 221 } 220 222 221 223 $write_data = array(); 222 224 223 - $need_raw = $this->loadRawContent($need_raw); 224 - foreach ($need_raw as $key => $paste) { 225 + $have_raw = $this->loadRawContent($need_raw); 226 + $have_raw = mpull($have_raw, null, 'getPHID'); 227 + foreach ($pastes as $key => $paste) { 228 + $paste_phid = $paste->getPHID(); 229 + if (isset($have_cache[$paste_phid])) { 230 + continue; 231 + } 232 + 233 + if (empty($have_raw[$paste_phid])) { 234 + unset($pastes[$key]); 235 + continue; 236 + } 237 + 225 238 $content = $this->buildContent($paste); 226 239 $paste->attachContent($content); 227 240 $write_data[$this->getContentCacheKey($paste)] = (string)$content; 228 241 } 229 242 230 - $cache->setKeys($write_data); 243 + if ($write_data) { 244 + $cache->setKeys($write_data); 245 + } 246 + 247 + return $pastes; 231 248 } 232 249 233 250 private function buildContent(PhabricatorPaste $paste) {