From e0861bf240cf09fac0d42e0d9bd616ed933a23ad Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 23 Jul 2015 13:26:40 -0700 Subject: [PATCH] Rename "HeraldAction" to "HeraldActionRecord" Summary: Ref T8726. I want to modularize actions like fields, but the base class should be "HeraldAction". Eventually, "HeraldCondition" should probably be "HeraldFieldRecord", and then both Action and Condition should just be rolled into Rule, probably, but that can wait and doesn't block anything. Test Plan: Ran migration, poked around UI, used `git grep`. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8726 Differential Revision: https://secure.phabricator.com/D13644 --- resources/sql/autopatches/20150606.mlist.1.php | 2 +- resources/sql/autopatches/20150717.herald.1.sql | 2 ++ src/__phutil_library_map__.php | 4 ++-- src/applications/herald/adapter/HeraldAdapter.php | 6 +++--- .../herald/controller/HeraldRuleController.php | 2 +- src/applications/herald/query/HeraldRuleQuery.php | 2 +- .../{HeraldAction.php => HeraldActionRecord.php} | 2 +- src/applications/herald/storage/HeraldRule.php | 10 +++++----- 8 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 resources/sql/autopatches/20150717.herald.1.sql rename src/applications/herald/storage/{HeraldAction.php => HeraldActionRecord.php} (91%) diff --git a/resources/sql/autopatches/20150606.mlist.1.php b/resources/sql/autopatches/20150606.mlist.1.php index 8090f28d69..5ba458b68d 100644 --- a/resources/sql/autopatches/20150606.mlist.1.php +++ b/resources/sql/autopatches/20150606.mlist.1.php @@ -99,7 +99,7 @@ foreach (new LiskMigrationIterator($table) as $condition) { echo pht('Updated mailing lists in Herald condition %d.', $id)."\n"; } -$table = new HeraldAction(); +$table = new HeraldActionRecord(); $conn_w = $table->establishConnection('w'); foreach (new LiskMigrationIterator($table) as $action) { $name = $action->getAction(); diff --git a/resources/sql/autopatches/20150717.herald.1.sql b/resources/sql/autopatches/20150717.herald.1.sql new file mode 100644 index 0000000000..aeb9f80301 --- /dev/null +++ b/resources/sql/autopatches/20150717.herald.1.sql @@ -0,0 +1,2 @@ +RENAME TABLE {$NAMESPACE}_herald.herald_action + TO {$NAMESPACE}_herald.herald_actionrecord; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 8d84b6e618..161914d921 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1007,7 +1007,7 @@ phutil_register_library_map(array( 'HarbormasterUploadArtifactBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterUploadArtifactBuildStepImplementation.php', 'HarbormasterWaitForPreviousBuildStepImplementation' => 'applications/harbormaster/step/HarbormasterWaitForPreviousBuildStepImplementation.php', 'HarbormasterWorker' => 'applications/harbormaster/worker/HarbormasterWorker.php', - 'HeraldAction' => 'applications/herald/storage/HeraldAction.php', + 'HeraldActionRecord' => 'applications/herald/storage/HeraldActionRecord.php', 'HeraldAdapter' => 'applications/herald/adapter/HeraldAdapter.php', 'HeraldAlwaysField' => 'applications/herald/field/HeraldAlwaysField.php', 'HeraldAnotherRuleField' => 'applications/herald/field/HeraldAnotherRuleField.php', @@ -4661,7 +4661,7 @@ phutil_register_library_map(array( 'HarbormasterUploadArtifactBuildStepImplementation' => 'HarbormasterBuildStepImplementation', 'HarbormasterWaitForPreviousBuildStepImplementation' => 'HarbormasterBuildStepImplementation', 'HarbormasterWorker' => 'PhabricatorWorker', - 'HeraldAction' => 'HeraldDAO', + 'HeraldActionRecord' => 'HeraldDAO', 'HeraldAdapter' => 'Phobject', 'HeraldAlwaysField' => 'HeraldField', 'HeraldAnotherRuleField' => 'HeraldField', diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php index b9623043e3..594de8dcbb 100644 --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -690,7 +690,7 @@ abstract class HeraldAdapter extends Phobject { public function willSaveAction( HeraldRule $rule, - HeraldAction $action) { + HeraldActionRecord $action) { $target = $action->getTarget(); if (is_array($target)) { @@ -996,7 +996,7 @@ abstract class HeraldAdapter extends Phobject { } private function renderActionAsText( - HeraldAction $action, + HeraldActionRecord $action, PhabricatorHandleList $handles) { $rule_global = HeraldRuleTypeConfig::RULE_TYPE_GLOBAL; @@ -1028,7 +1028,7 @@ abstract class HeraldAdapter extends Phobject { } private function renderActionTargetAsText( - HeraldAction $action, + HeraldActionRecord $action, PhabricatorHandleList $handles) { $target = $action->getTarget(); diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index 360fa4c181..5f447abffd 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -313,7 +313,7 @@ final class HeraldRuleController extends HeraldController { $action[1] = null; } - $obj = new HeraldAction(); + $obj = new HeraldActionRecord(); $obj->setAction($action[0]); $obj->setTarget($action[1]); diff --git a/src/applications/herald/query/HeraldRuleQuery.php b/src/applications/herald/query/HeraldRuleQuery.php index 5967c6ffc9..f4bd3fe734 100644 --- a/src/applications/herald/query/HeraldRuleQuery.php +++ b/src/applications/herald/query/HeraldRuleQuery.php @@ -108,7 +108,7 @@ final class HeraldRuleQuery extends PhabricatorCursorPagedPolicyAwareQuery { $rule_ids); $conditions = mgroup($conditions, 'getRuleID'); - $actions = id(new HeraldAction())->loadAllWhere( + $actions = id(new HeraldActionRecord())->loadAllWhere( 'ruleID IN (%Ld)', $rule_ids); $actions = mgroup($actions, 'getRuleID'); diff --git a/src/applications/herald/storage/HeraldAction.php b/src/applications/herald/storage/HeraldActionRecord.php similarity index 91% rename from src/applications/herald/storage/HeraldAction.php rename to src/applications/herald/storage/HeraldActionRecord.php index 4886567674..1ad4721b21 100644 --- a/src/applications/herald/storage/HeraldAction.php +++ b/src/applications/herald/storage/HeraldActionRecord.php @@ -1,6 +1,6 @@ getID()) { return array(); } - return id(new HeraldAction())->loadAllWhere( + return id(new HeraldActionRecord())->loadAllWhere( 'ruleID = %d', $this->getID()); } public function attachActions(array $actions) { // TODO: validate actions have been attached. - assert_instances_of($actions, 'HeraldAction'); + assert_instances_of($actions, 'HeraldActionRecord'); $this->actions = $actions; return $this; } @@ -123,9 +123,9 @@ final class HeraldRule extends HeraldDAO } public function saveActions(array $actions) { - assert_instances_of($actions, 'HeraldAction'); + assert_instances_of($actions, 'HeraldActionRecord'); return $this->saveChildren( - id(new HeraldAction())->getTableName(), + id(new HeraldActionRecord())->getTableName(), $actions); } @@ -162,7 +162,7 @@ final class HeraldRule extends HeraldDAO queryfx( $this->establishConnection('w'), 'DELETE FROM %T WHERE ruleID = %d', - id(new HeraldAction())->getTableName(), + id(new HeraldActionRecord())->getTableName(), $this->getID()); $result = parent::delete(); $this->saveTransaction();