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

Remove Herald rule edit log

Summary:
Fixes T7601. Ref T7803, weakly (this removes a Query subclass with ad-hoc paging). Herald has a very old edit log which predates transactions and is essentially useless and not really policy-aware. I think it's doing more harm than good; remove it.

Herald rules have proper transactions, but rule edits don't currently render something nice into the transaction log. This is definitely the way forward, but we haven't seen requests for this so don't bother building it for now.

I did put a nice end-cap on the transaction log, though.

Test Plan:
- Viewed Herald UI.
- Grepped for removed classes and methods.
- Edited a rule.
- Viewed rule transaction log.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: cburroughs, chad, epriestley

Maniphest Tasks: T7601, T7803

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

+4 -223
+1
resources/sql/autopatches/20150410.nukeruleedit.sql
··· 1 + DROP TABLE {$NAMESPACE}_herald.herald_ruleedit;
-8
src/__phutil_library_map__.php
··· 902 902 'HeraldDifferentialDiffAdapter' => 'applications/herald/adapter/HeraldDifferentialDiffAdapter.php', 903 903 'HeraldDifferentialRevisionAdapter' => 'applications/herald/adapter/HeraldDifferentialRevisionAdapter.php', 904 904 'HeraldDisableController' => 'applications/herald/controller/HeraldDisableController.php', 905 - 'HeraldEditLogQuery' => 'applications/herald/query/HeraldEditLogQuery.php', 906 905 'HeraldEffect' => 'applications/herald/engine/HeraldEffect.php', 907 906 'HeraldEngine' => 'applications/herald/engine/HeraldEngine.php', 908 907 'HeraldInvalidActionException' => 'applications/herald/engine/exception/HeraldInvalidActionException.php', ··· 920 919 'HeraldRepetitionPolicyConfig' => 'applications/herald/config/HeraldRepetitionPolicyConfig.php', 921 920 'HeraldRule' => 'applications/herald/storage/HeraldRule.php', 922 921 'HeraldRuleController' => 'applications/herald/controller/HeraldRuleController.php', 923 - 'HeraldRuleEdit' => 'applications/herald/storage/HeraldRuleEdit.php', 924 - 'HeraldRuleEditHistoryController' => 'applications/herald/controller/HeraldRuleEditHistoryController.php', 925 - 'HeraldRuleEditHistoryView' => 'applications/herald/view/HeraldRuleEditHistoryView.php', 926 922 'HeraldRuleEditor' => 'applications/herald/editor/HeraldRuleEditor.php', 927 923 'HeraldRuleListController' => 'applications/herald/controller/HeraldRuleListController.php', 928 924 'HeraldRulePHIDType' => 'applications/herald/phid/HeraldRulePHIDType.php', ··· 4146 4142 'HeraldDifferentialDiffAdapter' => 'HeraldDifferentialAdapter', 4147 4143 'HeraldDifferentialRevisionAdapter' => 'HeraldDifferentialAdapter', 4148 4144 'HeraldDisableController' => 'HeraldController', 4149 - 'HeraldEditLogQuery' => 'PhabricatorOffsetPagedQuery', 4150 4145 'HeraldInvalidActionException' => 'Exception', 4151 4146 'HeraldInvalidConditionException' => 'Exception', 4152 4147 'HeraldManageGlobalRulesCapability' => 'PhabricatorPolicyCapability', ··· 4166 4161 'PhabricatorDestructibleInterface', 4167 4162 ), 4168 4163 'HeraldRuleController' => 'HeraldController', 4169 - 'HeraldRuleEdit' => 'HeraldDAO', 4170 - 'HeraldRuleEditHistoryController' => 'HeraldController', 4171 - 'HeraldRuleEditHistoryView' => 'AphrontView', 4172 4164 'HeraldRuleEditor' => 'PhabricatorApplicationTransactionEditor', 4173 4165 'HeraldRuleListController' => 'HeraldController', 4174 4166 'HeraldRulePHIDType' => 'PhabricatorPHIDType',
-1
src/applications/herald/application/PhabricatorHeraldApplication.php
··· 54 54 'edit/(?:(?P<id>[1-9]\d*)/)?' => 'HeraldRuleController', 55 55 'disable/(?P<id>[1-9]\d*)/(?P<action>\w+)/' 56 56 => 'HeraldDisableController', 57 - 'history/(?:(?P<id>[1-9]\d*)/)?' => 'HeraldRuleEditHistoryController', 58 57 'test/' => 'HeraldTestConsoleController', 59 58 'transcript/' => array( 60 59 '' => 'HeraldTranscriptListController',
+2 -3
src/applications/herald/controller/HeraldController.php
··· 48 48 49 49 $nav 50 50 ->addLabel(pht('Utilities')) 51 - ->addFilter('test', pht('Test Console')) 52 - ->addFilter('transcript', pht('Transcripts')) 53 - ->addFilter('history', pht('Edit Log')); 51 + ->addFilter('test', pht('Test Console')) 52 + ->addFilter('transcript', pht('Transcripts')); 54 53 55 54 $nav->selectFilter(null); 56 55
-1
src/applications/herald/controller/HeraldRuleController.php
··· 328 328 $rule->save(); 329 329 $rule->saveConditions($conditions); 330 330 $rule->saveActions($actions); 331 - $rule->logEdit($request->getUser()->getPHID(), $edit_action); 332 331 $rule->saveTransaction(); 333 332 } 334 333
-55
src/applications/herald/controller/HeraldRuleEditHistoryController.php
··· 1 - <?php 2 - 3 - final class HeraldRuleEditHistoryController extends HeraldController { 4 - 5 - private $id; 6 - 7 - public function willProcessRequest(array $data) { 8 - $this->id = idx($data, 'id'); 9 - } 10 - 11 - public function processRequest() { 12 - $request = $this->getRequest(); 13 - 14 - $edit_query = new HeraldEditLogQuery(); 15 - if ($this->id) { 16 - $edit_query->withRuleIDs(array($this->id)); 17 - } 18 - 19 - $pager = new AphrontPagerView(); 20 - $pager->setURI($request->getRequestURI(), 'offset'); 21 - $pager->setOffset($request->getStr('offset')); 22 - 23 - $edits = $edit_query->executeWithOffsetPager($pager); 24 - 25 - $need_phids = mpull($edits, 'getEditorPHID'); 26 - $handles = $this->loadViewerHandles($need_phids); 27 - 28 - $list_view = id(new HeraldRuleEditHistoryView()) 29 - ->setEdits($edits) 30 - ->setHandles($handles) 31 - ->setUser($this->getRequest()->getUser()); 32 - 33 - $panel = new PHUIObjectBoxView(); 34 - $panel->setHeaderText(pht('Edit History')); 35 - $panel->appendChild($list_view); 36 - 37 - $crumbs = $this 38 - ->buildApplicationCrumbs($can_create = false) 39 - ->addTextCrumb( 40 - pht('Edit History'), 41 - $this->getApplicationURI('herald/history')); 42 - 43 - $nav = $this->buildSideNavView(); 44 - $nav->selectFilter('history'); 45 - $nav->appendChild($panel); 46 - $nav->setCrumbs($crumbs); 47 - 48 - return $this->buildApplicationPage( 49 - $nav, 50 - array( 51 - 'title' => pht('Rule Edit History'), 52 - )); 53 - } 54 - 55 - }
+1
src/applications/herald/controller/HeraldRuleViewController.php
··· 53 53 $timeline = $this->buildTransactionTimeline( 54 54 $rule, 55 55 new HeraldTransactionQuery()); 56 + $timeline->setShouldTerminate(true); 56 57 57 58 return $this->buildApplicationPage( 58 59 array(
-48
src/applications/herald/query/HeraldEditLogQuery.php
··· 1 - <?php 2 - 3 - final class HeraldEditLogQuery extends PhabricatorOffsetPagedQuery { 4 - 5 - private $ruleIDs; 6 - 7 - public function withRuleIDs(array $rule_ids) { 8 - $this->ruleIDs = $rule_ids; 9 - return $this; 10 - } 11 - 12 - public function execute() { 13 - $table = new HeraldRuleEdit(); 14 - $conn_r = $table->establishConnection('r'); 15 - 16 - $where = $this->buildWhereClause($conn_r); 17 - $order = $this->buildOrderClause($conn_r); 18 - $limit = $this->buildLimitClause($conn_r); 19 - 20 - $data = queryfx_all( 21 - $conn_r, 22 - 'SELECT log.* FROM %T log %Q %Q %Q', 23 - $table->getTableName(), 24 - $where, 25 - $order, 26 - $limit); 27 - 28 - return $table->loadAllFromArray($data); 29 - } 30 - 31 - private function buildWhereClause($conn_r) { 32 - $where = array(); 33 - 34 - if ($this->ruleIDs) { 35 - $where[] = qsprintf( 36 - $conn_r, 37 - 'ruleID IN (%Ld)', 38 - $this->ruleIDs); 39 - } 40 - 41 - return $this->formatWhereClause($where); 42 - } 43 - 44 - private function buildOrderClause($conn_r) { 45 - return 'ORDER BY id DESC'; 46 - } 47 - 48 - }
-20
src/applications/herald/storage/HeraldRule.php
··· 115 115 return $this->actions; 116 116 } 117 117 118 - public function loadEdits() { 119 - if (!$this->getID()) { 120 - return array(); 121 - } 122 - $edits = id(new HeraldRuleEdit())->loadAllWhere( 123 - 'ruleID = %d ORDER BY dateCreated DESC', 124 - $this->getID()); 125 - 126 - return $edits; 127 - } 128 - 129 - public function logEdit($editor_phid, $action) { 130 - id(new HeraldRuleEdit()) 131 - ->setRuleID($this->getID()) 132 - ->setRuleName($this->getName()) 133 - ->setEditorPHID($editor_phid) 134 - ->setAction($action) 135 - ->save(); 136 - } 137 - 138 118 public function saveConditions(array $conditions) { 139 119 assert_instances_of($conditions, 'HeraldCondition'); 140 120 return $this->saveChildren(
-24
src/applications/herald/storage/HeraldRuleEdit.php
··· 1 - <?php 2 - 3 - final class HeraldRuleEdit extends HeraldDAO { 4 - 5 - protected $editorPHID; 6 - protected $ruleID; 7 - protected $ruleName; 8 - protected $action; 9 - 10 - protected function getConfiguration() { 11 - return array( 12 - self::CONFIG_COLUMN_SCHEMA => array( 13 - 'ruleName' => 'text255', 14 - 'action' => 'text32', 15 - ), 16 - self::CONFIG_KEY_SCHEMA => array( 17 - 'ruleID' => array( 18 - 'columns' => array('ruleID', 'dateCreated'), 19 - ), 20 - ), 21 - ) + parent::getConfiguration(); 22 - } 23 - 24 - }
-63
src/applications/herald/view/HeraldRuleEditHistoryView.php
··· 1 - <?php 2 - 3 - final class HeraldRuleEditHistoryView extends AphrontView { 4 - 5 - private $edits; 6 - private $handles; 7 - 8 - public function setEdits(array $edits) { 9 - $this->edits = $edits; 10 - return $this; 11 - } 12 - 13 - public function getEdits() { 14 - return $this->edits; 15 - } 16 - 17 - public function setHandles(array $handles) { 18 - assert_instances_of($handles, 'PhabricatorObjectHandle'); 19 - $this->handles = $handles; 20 - return $this; 21 - } 22 - 23 - public function render() { 24 - $list = new PHUIObjectItemListView(); 25 - $list->setFlush(true); 26 - 27 - foreach ($this->edits as $edit) { 28 - $name = nonempty($edit->getRuleName(), 'Unknown Rule'); 29 - $rule_name = phutil_tag( 30 - 'strong', 31 - array(), 32 - $name); 33 - 34 - switch ($edit->getAction()) { 35 - case 'create': 36 - $details = pht("Created rule '%s'.", $rule_name); 37 - break; 38 - case 'delete': 39 - $details = pht("Deleted rule '%s'.", $rule_name); 40 - break; 41 - case 'edit': 42 - default: 43 - $details = pht("Edited rule '%s'.", $rule_name); 44 - break; 45 - } 46 - 47 - $editor = $this->handles[$edit->getEditorPHID()]->renderLink(); 48 - $date = phabricator_datetime($edit->getDateCreated(), $this->user); 49 - 50 - $item = id(new PHUIObjectItemView()) 51 - ->setObjectName(pht('Rule %d', $edit->getRuleID())) 52 - ->setSubHead($details) 53 - ->addIcon('none', $date) 54 - ->addByLine(pht('Editor: %s', $editor)); 55 - 56 - $list->addItem($item); 57 - } 58 - 59 - $list->setNoDataString(pht('No edits for rule.')); 60 - 61 - return $list; 62 - } 63 - }