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

Fix an issue where the Herald test console doesn't work with "Content source" rules

Summary:
Ref T13130. See PHI619. Currently, the Herald "Test Console" doesn't pass a "Content Source" to the adapter, so if any rules of the given type execute a "Content source" field rule, they'll fatal.

Provide a content source:

- If possible, use the content source from the most recent transaction.
- Otherwise, build a default "web" content source from the current request.

Test Plan:
- Wrote a "When [content source][is][whatever]" rule for tasks.
- Ran test console against a task.
- Before: got a fatal trying to interact with the content source.
- After: transcript reports sensible content source.
- Also commented out the "xaction" logic to test the fallback behavior.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13130

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

+27
+27
src/applications/herald/controller/HeraldTestConsoleController.php
··· 38 38 39 39 $object = $this->getTestObject(); 40 40 $adapter = $this->getTestAdapter(); 41 + $source = $this->newContentSource($object); 41 42 42 43 $adapter 44 + ->setContentSource($source) 43 45 ->setIsNewObject(false) 44 46 ->setActingAsPHID($viewer->getPHID()) 45 47 ->setViewer($viewer); ··· 216 218 ->setTitle($title) 217 219 ->setCrumbs($crumbs) 218 220 ->appendChild($view); 221 + } 222 + 223 + private function newContentSource($object) { 224 + $viewer = $this->getViewer(); 225 + 226 + // Try using the content source associated with the most recent transaction 227 + // on the object. 228 + 229 + $query = PhabricatorApplicationTransactionQuery::newQueryForObject($object); 230 + 231 + $xaction = $query 232 + ->setViewer($viewer) 233 + ->withObjectPHIDs(array($object->getPHID())) 234 + ->setLimit(1) 235 + ->setOrder('newest') 236 + ->executeOne(); 237 + if ($xaction) { 238 + return $xaction->getContentSource(); 239 + } 240 + 241 + // If we couldn't find a transaction (which should be rare), fall back to 242 + // building a new content source from the test console request itself. 243 + 244 + $request = $this->getRequest(); 245 + return PhabricatorContentSource::newFromRequest($request); 219 246 } 220 247 221 248 }