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

Dispatch Differential edit events from Editor, not Controller

Summary:
Currently, these events don't fire for Conduit updates, which makes them sort of silly.

This will get proper treatment after T2222.

Test Plan: Installed a `throw new Exception(...)` event listener. Performed Conduit and web updates of revisions, saw event listener fire.

Reviewers: btrahan, guywarner

Reviewed By: guywarner

CC: aran

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

+39 -22
+1 -21
src/applications/differential/controller/DifferentialRevisionEditController.php
··· 67 67 $is_new = !$revision->getID(); 68 68 $user = $request->getUser(); 69 69 70 - $event = new PhabricatorEvent( 71 - PhabricatorEventType::TYPE_DIFFERENTIAL_WILLEDITREVISION, 72 - array( 73 - 'revision' => $revision, 74 - 'new' => $is_new, 75 - )); 76 - 77 - $event->setUser($user); 78 - $event->setAphrontRequest($request); 79 - PhutilEventEngine::dispatchEvent($event); 80 - 81 70 $editor = new DifferentialRevisionEditor($revision); 82 71 $editor->setActor($request->getUser()); 83 72 if ($diff) { 84 73 $editor->addDiff($diff, $request->getStr('comments')); 85 74 } 86 75 $editor->setAuxiliaryFields($aux_fields); 76 + $editor->setAphrontRequestForEventDispatch($request); 87 77 $editor->save(); 88 - 89 - $event = new PhabricatorEvent( 90 - PhabricatorEventType::TYPE_DIFFERENTIAL_DIDEDITREVISION, 91 - array( 92 - 'revision' => $revision, 93 - 'new' => $is_new, 94 - )); 95 - $event->setUser($user); 96 - $event->setAphrontRequest($request); 97 - PhutilEventEngine::dispatchEvent($event); 98 78 99 79 return id(new AphrontRedirectResponse()) 100 80 ->setURI('/D'.$revision->getID());
+37
src/applications/differential/editor/DifferentialRevisionEditor.php
··· 17 17 18 18 private $auxiliaryFields = array(); 19 19 private $contentSource; 20 + private $isCreate; 21 + private $aphrontRequestForEventDispatch; 22 + 23 + 24 + public function setAphrontRequestForEventDispatch(AphrontRequest $request) { 25 + $this->aphrontRequestForEventDispatch = $request; 26 + return $this; 27 + } 28 + 29 + public function getAphrontRequestForEventDispatch() { 30 + return $this->aphrontRequestForEventDispatch; 31 + } 20 32 21 33 public function __construct(DifferentialRevision $revision) { 22 34 $this->revision = $revision; 35 + $this->isCreate = !($revision->getID()); 23 36 } 24 37 25 38 public static function newRevisionFromConduitWithDiff( ··· 844 857 foreach ($this->auxiliaryFields as $aux_field) { 845 858 $aux_field->willWriteRevision($this); 846 859 } 860 + 861 + $this->dispatchEvent( 862 + PhabricatorEventType::TYPE_DIFFERENTIAL_WILLEDITREVISION); 847 863 } 848 864 849 865 private function didWriteRevision() { 850 866 foreach ($this->auxiliaryFields as $aux_field) { 851 867 $aux_field->didWriteRevision($this); 852 868 } 869 + 870 + $this->dispatchEvent( 871 + PhabricatorEventType::TYPE_DIFFERENTIAL_DIDEDITREVISION); 872 + } 873 + 874 + private function dispatchEvent($type) { 875 + $event = new PhabricatorEvent( 876 + $type, 877 + array( 878 + 'revision' => $this->revision, 879 + 'new' => $this->isCreate, 880 + )); 881 + 882 + $event->setUser($this->getActor()); 883 + 884 + $request = $this->getAphrontRequestForEventDispatch(); 885 + if ($request) { 886 + $event->setAphrontRequest($request); 887 + } 888 + 889 + PhutilEventEngine::dispatchEvent($event); 853 890 } 854 891 855 892 /**
+1 -1
src/applications/differential/field/specification/DifferentialJIRAIssuesFieldSpecification.php
··· 38 38 ->setCaption( 39 39 pht('Example: %s', phutil_tag('tt', array(), 'JIS-3, JIS-9'))) 40 40 ->setName($this->getStorageKey()) 41 - ->setValue(implode(', ', $this->value)) 41 + ->setValue(implode(', ', nonempty($this->value, array()))) 42 42 ->setError($this->error); 43 43 } 44 44