@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

Fix undefined ACTION_BLOCK class constant in Herald

Summary: Fixes T9054. This didn't get fully cleaned up.

Test Plan: Edited several rules, saw actions faithfully represented.

Reviewers: joshuaspence, chad

Reviewed By: chad

Maniphest Tasks: T9054

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

+34 -21
+17
src/applications/herald/action/HeraldAction.php
··· 86 86 return $value; 87 87 } 88 88 89 + public function getEditorValue(PhabricatorUser $viewer, $target) { 90 + try { 91 + $type = $this->getHeraldActionStandardType(); 92 + } catch (PhutilMethodNotImplementedException $ex) { 93 + return $target; 94 + } 95 + 96 + switch ($type) { 97 + case self::STANDARD_PHID_LIST: 98 + $handles = $viewer->loadHandles($target); 99 + $handles = iterator_to_array($handles); 100 + return mpull($handles, 'getName', 'getPHID'); 101 + } 102 + 103 + return $target; 104 + } 105 + 89 106 final public function setAdapter(HeraldAdapter $adapter) { 90 107 $this->adapter = $adapter; 91 108 return $this;
+12 -2
src/applications/herald/adapter/HeraldAdapter.php
··· 770 770 771 771 public function getEditorValueForCondition( 772 772 PhabricatorUser $viewer, 773 - HeraldCondition $condition, 774 - array $handles) { 773 + HeraldCondition $condition) { 775 774 776 775 $field = $this->requireFieldImplementation($condition->getFieldName()); 777 776 ··· 779 778 $viewer, 780 779 $condition->getFieldCondition(), 781 780 $condition->getValue()); 781 + } 782 + 783 + public function getEditorValueForAction( 784 + PhabricatorUser $viewer, 785 + HeraldActionRecord $action_record) { 786 + 787 + $action = $this->requireActionImplementation($action_record->getAction()); 788 + 789 + return $action->getEditorValue( 790 + $viewer, 791 + $action_record->getTarget()); 782 792 } 783 793 784 794 public function renderRuleAsText(
+5 -19
src/applications/herald/controller/HeraldRuleController.php
··· 348 348 foreach ($rule->getConditions() as $condition) { 349 349 $value = $adapter->getEditorValueForCondition( 350 350 $this->getViewer(), 351 - $condition, 352 - $handles); 351 + $condition); 353 352 354 353 $serial_conditions[] = array( 355 354 $condition->getFieldName(), ··· 366 365 if ($rule->getActions()) { 367 366 $serial_actions = array(); 368 367 foreach ($rule->getActions() as $action) { 369 - switch ($action->getAction()) { 370 - case HeraldAdapter::ACTION_BLOCK: 371 - $current_value = $action->getTarget(); 372 - break; 373 - default: 374 - if (is_array($action->getTarget())) { 375 - $target_map = array(); 376 - foreach ((array)$action->getTarget() as $fbid) { 377 - $target_map[$fbid] = $handles[$fbid]->getName(); 378 - } 379 - $current_value = $target_map; 380 - } else { 381 - $current_value = $action->getTarget(); 382 - } 383 - break; 384 - } 368 + $value = $adapter->getEditorValueForAction( 369 + $this->getViewer(), 370 + $action); 385 371 386 372 $serial_actions[] = array( 387 373 $action->getAction(), 388 - $current_value, 374 + $value, 389 375 ); 390 376 } 391 377 }