From ab3c17a2cd97464b8eeb725d57515587d14918e5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 16 Jul 2014 17:12:38 -0700 Subject: [PATCH 01/44] Emit more usable results from phrequent.tracking Summary: I think this pretty much does what you would expect? The "active" item is always at the top of the stack. Test Plan: Called `phrequent.tracking` and got reasonable results. Reviewers: hach-que Reviewed By: hach-que Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D9939 --- src/__phutil_library_map__.php | 2 + .../ConduitAPI_phrequent_tracking_Method.php | 1 + .../query/PhrequentUserTimeQuery.php | 2 +- .../phrequent/storage/PhrequentTimeBlock.php | 82 ++++++++++------- .../phrequent/storage/PhrequentTimeSlices.php | 37 ++++++++ .../__tests__/PhrequentTimeBlockTestCase.php | 89 +++++++++++++++++-- 6 files changed, 173 insertions(+), 40 deletions(-) create mode 100644 src/applications/phrequent/storage/PhrequentTimeSlices.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index b3385d487b..165aca029b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2550,6 +2550,7 @@ phutil_register_library_map(array( 'PhrequentSearchEngine' => 'applications/phrequent/query/PhrequentSearchEngine.php', 'PhrequentTimeBlock' => 'applications/phrequent/storage/PhrequentTimeBlock.php', 'PhrequentTimeBlockTestCase' => 'applications/phrequent/storage/__tests__/PhrequentTimeBlockTestCase.php', + 'PhrequentTimeSlices' => 'applications/phrequent/storage/PhrequentTimeSlices.php', 'PhrequentTrackController' => 'applications/phrequent/controller/PhrequentTrackController.php', 'PhrequentTrackableInterface' => 'applications/phrequent/interface/PhrequentTrackableInterface.php', 'PhrequentTrackingEditor' => 'applications/phrequent/editor/PhrequentTrackingEditor.php', @@ -5521,6 +5522,7 @@ phutil_register_library_map(array( 'PhrequentSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhrequentTimeBlock' => 'Phobject', 'PhrequentTimeBlockTestCase' => 'PhabricatorTestCase', + 'PhrequentTimeSlices' => 'Phobject', 'PhrequentTrackController' => 'PhrequentController', 'PhrequentTrackingEditor' => 'PhabricatorEditor', 'PhrequentUIEventListener' => 'PhabricatorEventListener', diff --git a/src/applications/phrequent/conduit/ConduitAPI_phrequent_tracking_Method.php b/src/applications/phrequent/conduit/ConduitAPI_phrequent_tracking_Method.php index 7372caeb20..ba03602957 100644 --- a/src/applications/phrequent/conduit/ConduitAPI_phrequent_tracking_Method.php +++ b/src/applications/phrequent/conduit/ConduitAPI_phrequent_tracking_Method.php @@ -31,6 +31,7 @@ final class ConduitAPI_phrequent_tracking_Method $times = id(new PhrequentUserTimeQuery()) ->setViewer($user) ->needPreemptingEvents(true) + ->withEnded(PhrequentUserTimeQuery::ENDED_NO) ->withUserPHIDs(array($user->getPHID())) ->execute(); diff --git a/src/applications/phrequent/query/PhrequentUserTimeQuery.php b/src/applications/phrequent/query/PhrequentUserTimeQuery.php index 190be7652b..9fc382674b 100644 --- a/src/applications/phrequent/query/PhrequentUserTimeQuery.php +++ b/src/applications/phrequent/query/PhrequentUserTimeQuery.php @@ -199,7 +199,7 @@ final class PhrequentUserTimeQuery $u_start = $u_event->getDateStarted(); $u_end = $u_event->getDateEnded(); - if (($u_start >= $e_start) && ($u_end <= $e_end) && + if (($u_start >= $e_start) && ($u_end === null || $u_end > $e_start)) { $select[] = $u_event; } diff --git a/src/applications/phrequent/storage/PhrequentTimeBlock.php b/src/applications/phrequent/storage/PhrequentTimeBlock.php index a625e2d2f9..ee5fd00a44 100644 --- a/src/applications/phrequent/storage/PhrequentTimeBlock.php +++ b/src/applications/phrequent/storage/PhrequentTimeBlock.php @@ -10,17 +10,16 @@ final class PhrequentTimeBlock extends Phobject { } public function getTimeSpentOnObject($phid, $now) { - $ranges = idx($this->getObjectTimeRanges($now), $phid, array()); + $slices = idx($this->getObjectTimeRanges(), $phid); - $sum = 0; - foreach ($ranges as $range) { - $sum += ($range[1] - $range[0]); + if (!$slices) { + return null; } - return $sum; + return $slices->getDuration($now); } - public function getObjectTimeRanges($now) { + public function getObjectTimeRanges() { $ranges = array(); $range_start = time(); @@ -29,6 +28,7 @@ final class PhrequentTimeBlock extends Phobject { } $object_ranges = array(); + $object_ongoing = array(); foreach ($this->events as $event) { // First, convert each event's preempting stack into a linear timeline @@ -42,14 +42,16 @@ final class PhrequentTimeBlock extends Phobject { ); $timeline[] = array( 'event' => $event, - 'at' => (int)nonempty($event->getDateEnded(), $now), + 'at' => (int)nonempty($event->getDateEnded(), PHP_INT_MAX), 'type' => 'end', ); $base_phid = $event->getObjectPHID(); + if (!$event->getDateEnded()) { + $object_ongoing[$base_phid] = true; + } $preempts = $event->getPreemptingEvents(); - foreach ($preempts as $preempt) { $same_object = ($preempt->getObjectPHID() == $base_phid); $timeline[] = array( @@ -59,7 +61,7 @@ final class PhrequentTimeBlock extends Phobject { ); $timeline[] = array( 'event' => $preempt, - 'at' => (int)nonempty($preempt->getDateEnded(), $now), + 'at' => (int)nonempty($preempt->getDateEnded(), PHP_INT_MAX), 'type' => $same_object ? 'end' : 'pop', ); } @@ -89,7 +91,6 @@ final class PhrequentTimeBlock extends Phobject { $stratum = null; $strata = array(); - $ranges = array(); foreach ($timeline as $timeline_event) { $id = $timeline_event['event']->getID(); @@ -173,15 +174,39 @@ final class PhrequentTimeBlock extends Phobject { } } + // Filter out ranges with an indefinite start time. These occur when + // popping the stack when there are multiple ongoing events. + foreach ($ranges as $key => $range) { + if ($range[0] == PHP_INT_MAX) { + unset($ranges[$key]); + } + } + $object_ranges[$base_phid][] = $ranges; } - // Finally, collapse all the ranges so we don't double-count time. - + // Collapse all the ranges so we don't double-count time. foreach ($object_ranges as $phid => $ranges) { $object_ranges[$phid] = self::mergeTimeRanges(array_mergev($ranges)); } + foreach ($object_ranges as $phid => $ranges) { + foreach ($ranges as $key => $range) { + if ($range[1] == PHP_INT_MAX) { + $ranges[$key][1] = null; + } + } + + $object_ranges[$phid] = new PhrequentTimeSlices( + $phid, + isset($object_ongoing[$phid]), + $ranges); + } + + // Reorder the ranges to be more stack-like, so the first item is the + // top of the stack. + $object_ranges = array_reverse($object_ranges, $preserve_keys = true); + return $object_ranges; } @@ -189,33 +214,22 @@ final class PhrequentTimeBlock extends Phobject { * Returns the current list of work. */ public function getCurrentWorkStack($now, $include_inactive = false) { - $ranges = $this->getObjectTimeRanges($now); + $ranges = $this->getObjectTimeRanges(); $results = array(); - foreach ($ranges as $phid => $blocks) { - $total = 0; - foreach ($blocks as $block) { - $total += $block[1] - $block[0]; - } - - $type = 'inactive'; - foreach ($blocks as $block) { - if ($block[1] === $now) { - if ($block[0] === $block[1]) { - $type = 'suspended'; - } else { - $type = 'active'; - } - break; + $active = null; + foreach ($ranges as $phid => $slices) { + if (!$include_inactive) { + if (!$slices->getIsOngoing()) { + continue; } } - if ($include_inactive || $type !== 'inactive') { - $results[] = array( - 'phid' => $phid, - 'time' => $total, - 'type' => $type); - } + $results[] = array( + 'phid' => $phid, + 'time' => $slices->getDuration($now), + 'ongoing' => $slices->getIsOngoing(), + ); } return $results; diff --git a/src/applications/phrequent/storage/PhrequentTimeSlices.php b/src/applications/phrequent/storage/PhrequentTimeSlices.php new file mode 100644 index 0000000000..30c4345720 --- /dev/null +++ b/src/applications/phrequent/storage/PhrequentTimeSlices.php @@ -0,0 +1,37 @@ +objectPHID = $object_phid; + $this->isOngoing = $is_ongoing; + $this->ranges = $ranges; + } + + public function getObjectPHID() { + return $this->objectPHID; + } + + public function getDuration($now) { + foreach ($this->ranges as $range) { + if ($range[1] === null) { + return $now - $range[0]; + } else { + return $range[1] - $range[0]; + } + } + } + + public function getIsOngoing() { + return $this->isOngoing; + } + + public function getRanges() { + return $this->ranges; + } + +} diff --git a/src/applications/phrequent/storage/__tests__/PhrequentTimeBlockTestCase.php b/src/applications/phrequent/storage/__tests__/PhrequentTimeBlockTestCase.php index 6bb09b5497..d42560090e 100644 --- a/src/applications/phrequent/storage/__tests__/PhrequentTimeBlockTestCase.php +++ b/src/applications/phrequent/storage/__tests__/PhrequentTimeBlockTestCase.php @@ -86,7 +86,9 @@ final class PhrequentTimeBlockTestCase extends PhabricatorTestCase { $block = new PhrequentTimeBlock(array($event)); - $ranges = $block->getObjectTimeRanges(1800); + $ranges = $block->getObjectTimeRanges(); + $ranges = $this->reduceRanges($ranges); + $this->assertEqual( array( 'T1' => array( @@ -107,7 +109,9 @@ final class PhrequentTimeBlockTestCase extends PhabricatorTestCase { $block = new PhrequentTimeBlock(array($event)); - $ranges = $block->getObjectTimeRanges(1000); + $ranges = $block->getObjectTimeRanges(); + $ranges = $this->reduceRanges($ranges); + $this->assertEqual( array( 'T2' => array( @@ -150,7 +154,9 @@ final class PhrequentTimeBlockTestCase extends PhabricatorTestCase { $block = new PhrequentTimeBlock(array($event)); - $ranges = $block->getObjectTimeRanges(1800); + $ranges = $block->getObjectTimeRanges(); + $ranges = $this->reduceRanges($ranges); + $this->assertEqual( array( 'T1' => array( @@ -172,7 +178,8 @@ final class PhrequentTimeBlockTestCase extends PhabricatorTestCase { $block = new PhrequentTimeBlock(array($event)); - $ranges = $block->getObjectTimeRanges(1000); + $ranges = $block->getObjectTimeRanges(); + $ranges = $this->reduceRanges($ranges); $this->assertEqual( array( @@ -198,7 +205,8 @@ final class PhrequentTimeBlockTestCase extends PhabricatorTestCase { $block = new PhrequentTimeBlock(array($event)); - $ranges = $block->getObjectTimeRanges(1000); + $ranges = $block->getObjectTimeRanges(); + $ranges = $this->reduceRanges($ranges); $this->assertEqual( array( @@ -213,6 +221,67 @@ final class PhrequentTimeBlockTestCase extends PhabricatorTestCase { $ranges); } + public function testOngoing() { + $event = $this->newEvent('T1', 1, null); + $event->attachPreemptingEvents(array()); + + $block = new PhrequentTimeBlock(array($event)); + + $ranges = $block->getObjectTimeRanges(); + $ranges = $this->reduceRanges($ranges); + + $this->assertEqual( + array( + 'T1' => array( + array(1, null), + ), + ), + $ranges); + } + + public function testOngoingInterrupted() { + $event = $this->newEvent('T1', 1, null); + $event->attachPreemptingEvents( + array( + $this->newEvent('T2', 100, 900), + )); + + $block = new PhrequentTimeBlock(array($event)); + + $ranges = $block->getObjectTimeRanges(); + $ranges = $this->reduceRanges($ranges); + + $this->assertEqual( + array( + 'T1' => array( + array(1, 100), + array(900, null) + ), + ), + $ranges); + } + + public function testOngoingPreempted() { + $event = $this->newEvent('T1', 1, null); + $event->attachPreemptingEvents( + array( + $this->newEvent('T2', 100, null), + )); + + $block = new PhrequentTimeBlock(array($event)); + + $ranges = $block->getObjectTimeRanges(); + $ranges = $this->reduceRanges($ranges); + + $this->assertEqual( + array( + 'T1' => array( + array(1, 100), + ), + ), + $ranges); + } + private function newEvent($object_phid, $start_time, $end_time) { static $id = 0; @@ -223,4 +292,14 @@ final class PhrequentTimeBlockTestCase extends PhabricatorTestCase { ->setDateEnded($end_time); } + private function reduceRanges(array $ranges) { + $results = array(); + + foreach ($ranges as $phid => $slices) { + $results[$phid] = $slices->getRanges(); + } + + return $results; + } + } From 6bf4ec97d563cff2f9186bc4f042979e0f20ee77 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 14:48:54 -0700 Subject: [PATCH 02/44] Fix HTTP 400 from notification server for JSON subscription objects Summary: Fixes T5651. Sometime we'll send an object to the notification server for `subscribers`, which it will choke on. Use `array_values()` to make sure we're sending an array. Test Plan: With `(object)` instead, got a consistent error ("no .filter method on object"). With `array_values()`, no error. Reviewers: joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5651 Differential Revision: https://secure.phabricator.com/D9963 --- src/__phutil_library_map__.php | 328 ++++++------------ .../feed/PhabricatorFeedStoryPublisher.php | 2 +- support/aphlict/server/aphlict_server.js | 4 + 3 files changed, 115 insertions(+), 219 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 165aca029b..3262902c02 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2,13 +2,13 @@ /** * This file is automatically generated. Use 'arc liberate' to rebuild it. + * * @generated * @phutil-library-version 2 */ phutil_register_library_map(array( '__library_version__' => 2, - 'class' => - array( + 'class' => array( 'Aphront304Response' => 'aphront/response/Aphront304Response.php', 'Aphront400Response' => 'aphront/response/Aphront400Response.php', 'Aphront403Response' => 'aphront/response/Aphront403Response.php', @@ -2708,8 +2708,7 @@ phutil_register_library_map(array( 'SubscriptionListDialogBuilder' => 'applications/subscriptions/view/SubscriptionListDialogBuilder.php', 'SubscriptionListStringBuilder' => 'applications/subscriptions/view/SubscriptionListStringBuilder.php', ), - 'function' => - array( + 'function' => array( '_phabricator_time_format' => 'view/viewutils.php', 'celerity_generate_unique_node_id' => 'infrastructure/celerity/api.php', 'celerity_get_resource_uri' => 'infrastructure/celerity/api.php', @@ -2727,8 +2726,7 @@ phutil_register_library_map(array( 'phid_group_by_type' => 'applications/phid/utils.php', 'require_celerity_resource' => 'infrastructure/celerity/api.php', ), - 'xmap' => - array( + 'xmap' => array( 'Aphront304Response' => 'AphrontResponse', 'Aphront400Response' => 'AphrontResponse', 'Aphront403Response' => 'AphrontHTMLResponse', @@ -2805,8 +2803,7 @@ phutil_register_library_map(array( 'AphrontTwoColumnView' => 'AphrontView', 'AphrontTypeaheadTemplateView' => 'AphrontView', 'AphrontUsageException' => 'AphrontException', - 'AphrontView' => - array( + 'AphrontView' => array( 0 => 'Phobject', 1 => 'PhutilSafeHTMLProducerInterface', ), @@ -2823,8 +2820,7 @@ phutil_register_library_map(array( 'CelerityResourceGraph' => 'AbstractDirectedGraph', 'CelerityResourceTransformerTestCase' => 'PhabricatorTestCase', 'CelerityResourcesOnDisk' => 'CelerityPhysicalResources', - 'ConduitAPIMethod' => - array( + 'ConduitAPIMethod' => array( 0 => 'Phobject', 1 => 'PhabricatorPolicyInterface', ), @@ -3007,8 +3003,7 @@ phutil_register_library_map(array( 'ConpherencePeopleWidgetView' => 'ConpherenceWidgetView', 'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler', 'ConpherenceSettings' => 'ConpherenceConstants', - 'ConpherenceThread' => - array( + 'ConpherenceThread' => array( 0 => 'ConpherenceDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3046,8 +3041,7 @@ phutil_register_library_map(array( 'DifferentialBranchField' => 'DifferentialCustomField', 'DifferentialCapabilityDefaultView' => 'PhabricatorPolicyCapability', 'DifferentialChangesSinceLastUpdateField' => 'DifferentialCustomField', - 'DifferentialChangeset' => - array( + 'DifferentialChangeset' => array( 0 => 'DifferentialDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3080,8 +3074,7 @@ phutil_register_library_map(array( 'DifferentialDAO' => 'PhabricatorLiskDAO', 'DifferentialDependenciesField' => 'DifferentialCustomField', 'DifferentialDependsOnField' => 'DifferentialCustomField', - 'DifferentialDiff' => - array( + 'DifferentialDiff' => array( 0 => 'DifferentialDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'HarbormasterBuildableInterface', @@ -3102,8 +3095,7 @@ phutil_register_library_map(array( 'DifferentialGitSVNIDField' => 'DifferentialCustomField', 'DifferentialHostField' => 'DifferentialCustomField', 'DifferentialHovercardEventListener' => 'PhabricatorEventListener', - 'DifferentialHunk' => - array( + 'DifferentialHunk' => array( 0 => 'DifferentialDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3145,8 +3137,7 @@ phutil_register_library_map(array( 'DifferentialReviewedByField' => 'DifferentialCoreCustomField', 'DifferentialReviewersField' => 'DifferentialCoreCustomField', 'DifferentialReviewersView' => 'AphrontView', - 'DifferentialRevision' => - array( + 'DifferentialRevision' => array( 0 => 'DifferentialDAO', 1 => 'PhabricatorTokenReceiverInterface', 2 => 'PhabricatorPolicyInterface', @@ -3318,14 +3309,12 @@ phutil_register_library_map(array( 'DivinerFindController' => 'DivinerController', 'DivinerGenerateWorkflow' => 'DivinerWorkflow', 'DivinerLiveAtom' => 'DivinerDAO', - 'DivinerLiveBook' => - array( + 'DivinerLiveBook' => array( 0 => 'DivinerDAO', 1 => 'PhabricatorPolicyInterface', ), 'DivinerLivePublisher' => 'DivinerPublisher', - 'DivinerLiveSymbol' => - array( + 'DivinerLiveSymbol' => array( 0 => 'DivinerDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorMarkupInterface', @@ -3346,8 +3335,7 @@ phutil_register_library_map(array( 'DoorkeeperBridgeJIRA' => 'DoorkeeperBridge', 'DoorkeeperBridgeJIRATestCase' => 'PhabricatorTestCase', 'DoorkeeperDAO' => 'PhabricatorLiskDAO', - 'DoorkeeperExternalObject' => - array( + 'DoorkeeperExternalObject' => array( 0 => 'DoorkeeperDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3365,8 +3353,7 @@ phutil_register_library_map(array( 'DoorkeeperTagsController' => 'PhabricatorController', 'DrydockAllocatorWorker' => 'PhabricatorWorker', 'DrydockApacheWebrootInterface' => 'DrydockWebrootInterface', - 'DrydockBlueprint' => - array( + 'DrydockBlueprint' => array( 0 => 'DrydockDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3388,8 +3375,7 @@ phutil_register_library_map(array( 'DrydockController' => 'PhabricatorController', 'DrydockDAO' => 'PhabricatorLiskDAO', 'DrydockFilesystemInterface' => 'DrydockInterface', - 'DrydockLease' => - array( + 'DrydockLease' => array( 0 => 'DrydockDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3403,8 +3389,7 @@ phutil_register_library_map(array( 'DrydockLeaseViewController' => 'DrydockLeaseController', 'DrydockLocalCommandInterface' => 'DrydockCommandInterface', 'DrydockLocalHostBlueprintImplementation' => 'DrydockBlueprintImplementation', - 'DrydockLog' => - array( + 'DrydockLog' => array( 0 => 'DrydockDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3423,8 +3408,7 @@ phutil_register_library_map(array( 'DrydockPHIDTypeResource' => 'PhabricatorPHIDType', 'DrydockPreallocatedHostBlueprintImplementation' => 'DrydockBlueprintImplementation', 'DrydockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'DrydockResource' => - array( + 'DrydockResource' => array( 0 => 'DrydockDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3446,14 +3430,12 @@ phutil_register_library_map(array( 'FileCreateMailReceiver' => 'PhabricatorMailReceiver', 'FileMailReceiver' => 'PhabricatorObjectMailReceiver', 'FileReplyHandler' => 'PhabricatorMailReplyHandler', - 'HarbormasterBuild' => - array( + 'HarbormasterBuild' => array( 0 => 'HarbormasterDAO', 1 => 'PhabricatorPolicyInterface', ), 'HarbormasterBuildActionController' => 'HarbormasterController', - 'HarbormasterBuildArtifact' => - array( + 'HarbormasterBuildArtifact' => array( 0 => 'HarbormasterDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3462,20 +3444,17 @@ phutil_register_library_map(array( 'HarbormasterBuildEngine' => 'Phobject', 'HarbormasterBuildItem' => 'HarbormasterDAO', 'HarbormasterBuildItemQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'HarbormasterBuildLog' => - array( + 'HarbormasterBuildLog' => array( 0 => 'HarbormasterDAO', 1 => 'PhabricatorPolicyInterface', ), 'HarbormasterBuildLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'HarbormasterBuildMessage' => - array( + 'HarbormasterBuildMessage' => array( 0 => 'HarbormasterDAO', 1 => 'PhabricatorPolicyInterface', ), 'HarbormasterBuildMessageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'HarbormasterBuildPlan' => - array( + 'HarbormasterBuildPlan' => array( 0 => 'HarbormasterDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorSubscribableInterface', @@ -3488,14 +3467,12 @@ phutil_register_library_map(array( 'HarbormasterBuildPlanTransactionComment' => 'PhabricatorApplicationTransactionComment', 'HarbormasterBuildPlanTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'HarbormasterBuildStep' => - array( + 'HarbormasterBuildStep' => array( 0 => 'HarbormasterDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorCustomFieldInterface', ), - 'HarbormasterBuildStepCoreCustomField' => - array( + 'HarbormasterBuildStepCoreCustomField' => array( 0 => 'HarbormasterBuildStepCustomField', 1 => 'PhabricatorStandardCustomFieldInterface', ), @@ -3504,8 +3481,7 @@ phutil_register_library_map(array( 'HarbormasterBuildStepQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildStepTransaction' => 'PhabricatorApplicationTransaction', 'HarbormasterBuildStepTransactionQuery' => 'PhabricatorApplicationTransactionQuery', - 'HarbormasterBuildTarget' => - array( + 'HarbormasterBuildTarget' => array( 0 => 'HarbormasterDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3515,8 +3491,7 @@ phutil_register_library_map(array( 'HarbormasterBuildTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'HarbormasterBuildViewController' => 'HarbormasterController', 'HarbormasterBuildWorker' => 'HarbormasterWorker', - 'HarbormasterBuildable' => - array( + 'HarbormasterBuildable' => array( 0 => 'HarbormasterDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'HarbormasterBuildableInterface', @@ -3588,8 +3563,7 @@ phutil_register_library_map(array( 'HeraldPreCommitRefAdapter' => 'HeraldPreCommitAdapter', 'HeraldRecursiveConditionsException' => 'Exception', 'HeraldRemarkupRule' => 'PhabricatorRemarkupRuleObject', - 'HeraldRule' => - array( + 'HeraldRule' => array( 0 => 'HeraldDAO', 1 => 'PhabricatorFlaggableInterface', 2 => 'PhabricatorPolicyInterface', @@ -3608,8 +3582,7 @@ phutil_register_library_map(array( 'HeraldRuleViewController' => 'HeraldController', 'HeraldTestConsoleController' => 'HeraldController', 'HeraldTransactionQuery' => 'PhabricatorApplicationTransactionQuery', - 'HeraldTranscript' => - array( + 'HeraldTranscript' => array( 0 => 'HeraldDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3628,16 +3601,14 @@ phutil_register_library_map(array( 'LegalpadCapabilityDefaultView' => 'PhabricatorPolicyCapability', 'LegalpadController' => 'PhabricatorController', 'LegalpadDAO' => 'PhabricatorLiskDAO', - 'LegalpadDocument' => - array( + 'LegalpadDocument' => array( 0 => 'LegalpadDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorSubscribableInterface', 3 => 'PhabricatorApplicationTransactionInterface', 4 => 'PhabricatorDestructableInterface', ), - 'LegalpadDocumentBody' => - array( + 'LegalpadDocumentBody' => array( 0 => 'LegalpadDAO', 1 => 'PhabricatorMarkupInterface', ), @@ -3652,8 +3623,7 @@ phutil_register_library_map(array( 'LegalpadDocumentRemarkupRule' => 'PhabricatorRemarkupRuleObject', 'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine', 'LegalpadDocumentSignController' => 'LegalpadController', - 'LegalpadDocumentSignature' => - array( + 'LegalpadDocumentSignature' => array( 0 => 'LegalpadDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3689,8 +3659,7 @@ phutil_register_library_map(array( 'ManiphestCapabilityEditPriority' => 'PhabricatorPolicyCapability', 'ManiphestCapabilityEditProjects' => 'PhabricatorPolicyCapability', 'ManiphestCapabilityEditStatus' => 'PhabricatorPolicyCapability', - 'ManiphestConfiguredCustomField' => - array( + 'ManiphestConfiguredCustomField' => array( 0 => 'ManiphestCustomField', 1 => 'PhabricatorStandardCustomFieldInterface', ), @@ -3717,8 +3686,7 @@ phutil_register_library_map(array( 'ManiphestStatusConfigOptionType' => 'PhabricatorConfigJSONOptionType', 'ManiphestSubpriorityController' => 'ManiphestController', 'ManiphestSubscribeController' => 'ManiphestController', - 'ManiphestTask' => - array( + 'ManiphestTask' => array( 0 => 'ManiphestDAO', 1 => 'PhabricatorMarkupInterface', 2 => 'PhabricatorPolicyInterface', @@ -3760,8 +3728,7 @@ phutil_register_library_map(array( 'NuanceCapabilitySourceManage' => 'PhabricatorPolicyCapability', 'NuanceController' => 'PhabricatorController', 'NuanceDAO' => 'PhabricatorLiskDAO', - 'NuanceItem' => - array( + 'NuanceItem' => array( 0 => 'NuanceDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3778,8 +3745,7 @@ phutil_register_library_map(array( 'NuancePHIDTypeSource' => 'PhabricatorPHIDType', 'NuancePhabricatorFormSourceDefinition' => 'NuanceSourceDefinition', 'NuanceQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'NuanceQueue' => - array( + 'NuanceQueue' => array( 0 => 'NuanceDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3800,8 +3766,7 @@ phutil_register_library_map(array( 'NuanceRequestorTransactionComment' => 'PhabricatorApplicationTransactionComment', 'NuanceRequestorTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'NuanceRequestorViewController' => 'NuanceController', - 'NuanceSource' => - array( + 'NuanceSource' => array( 0 => 'NuanceDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3876,8 +3841,7 @@ phutil_register_library_map(array( 'PackageModifyMail' => 'PackageMail', 'PassphraseAbstractKey' => 'Phobject', 'PassphraseController' => 'PhabricatorController', - 'PassphraseCredential' => - array( + 'PassphraseCredential' => array( 0 => 'PassphraseDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -3999,14 +3963,12 @@ phutil_register_library_map(array( 'PhabricatorApplicationSystem' => 'PhabricatorApplication', 'PhabricatorApplicationTest' => 'PhabricatorApplication', 'PhabricatorApplicationTokens' => 'PhabricatorApplication', - 'PhabricatorApplicationTransaction' => - array( + 'PhabricatorApplicationTransaction' => array( 0 => 'PhabricatorLiskDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorDestructableInterface', ), - 'PhabricatorApplicationTransactionComment' => - array( + 'PhabricatorApplicationTransactionComment' => array( 0 => 'PhabricatorLiskDAO', 1 => 'PhabricatorMarkupInterface', 2 => 'PhabricatorPolicyInterface', @@ -4043,16 +4005,14 @@ phutil_register_library_map(array( 'PhabricatorApplicationsListController' => 'PhabricatorApplicationsController', 'PhabricatorAsanaConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController', - 'PhabricatorAuditComment' => - array( + 'PhabricatorAuditComment' => array( 0 => 'PhabricatorAuditDAO', 1 => 'PhabricatorMarkupInterface', ), 'PhabricatorAuditCommentEditor' => 'PhabricatorEditor', 'PhabricatorAuditController' => 'PhabricatorController', 'PhabricatorAuditDAO' => 'PhabricatorLiskDAO', - 'PhabricatorAuditInlineComment' => - array( + 'PhabricatorAuditInlineComment' => array( 0 => 'PhabricatorAuditDAO', 1 => 'PhabricatorInlineCommentInterface', ), @@ -4091,8 +4051,7 @@ phutil_register_library_map(array( 'PhabricatorAuthOldOAuthRedirectController' => 'PhabricatorAuthController', 'PhabricatorAuthOneTimeLoginController' => 'PhabricatorAuthController', 'PhabricatorAuthPHIDTypeAuthFactor' => 'PhabricatorPHIDType', - 'PhabricatorAuthProviderConfig' => - array( + 'PhabricatorAuthProviderConfig' => array( 0 => 'PhabricatorAuthDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4119,8 +4078,7 @@ phutil_register_library_map(array( 'PhabricatorAuthProviderPassword' => 'PhabricatorAuthProvider', 'PhabricatorAuthProviderPersona' => 'PhabricatorAuthProvider', 'PhabricatorAuthRegisterController' => 'PhabricatorAuthController', - 'PhabricatorAuthSession' => - array( + 'PhabricatorAuthSession' => array( 0 => 'PhabricatorAuthDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4128,8 +4086,7 @@ phutil_register_library_map(array( 'PhabricatorAuthSessionGarbageCollector' => 'PhabricatorGarbageCollector', 'PhabricatorAuthSessionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorAuthStartController' => 'PhabricatorAuthController', - 'PhabricatorAuthTemporaryToken' => - array( + 'PhabricatorAuthTemporaryToken' => array( 0 => 'PhabricatorAuthDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4168,8 +4125,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarBrowseController' => 'PhabricatorCalendarController', 'PhabricatorCalendarController' => 'PhabricatorController', 'PhabricatorCalendarDAO' => 'PhabricatorLiskDAO', - 'PhabricatorCalendarEvent' => - array( + 'PhabricatorCalendarEvent' => array( 0 => 'PhabricatorCalendarDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4187,8 +4143,7 @@ phutil_register_library_map(array( 'PhabricatorCampfireProtocolAdapter' => 'PhabricatorBotBaseStreamingProtocolAdapter', 'PhabricatorChangeParserTestCase' => 'PhabricatorWorkingCopyTestCase', 'PhabricatorChangesetResponse' => 'AphrontProxyResponse', - 'PhabricatorChatLogChannel' => - array( + 'PhabricatorChatLogChannel' => array( 0 => 'PhabricatorChatLogDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4197,8 +4152,7 @@ phutil_register_library_map(array( 'PhabricatorChatLogChannelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorChatLogController' => 'PhabricatorController', 'PhabricatorChatLogDAO' => 'PhabricatorLiskDAO', - 'PhabricatorChatLogEvent' => - array( + 'PhabricatorChatLogEvent' => array( 0 => 'PhabricatorChatLogDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4219,8 +4173,7 @@ phutil_register_library_map(array( 'PhabricatorConduitListController' => 'PhabricatorConduitController', 'PhabricatorConduitLogController' => 'PhabricatorConduitController', 'PhabricatorConduitLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'PhabricatorConduitMethodCallLog' => - array( + 'PhabricatorConduitMethodCallLog' => array( 0 => 'PhabricatorConduitDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4234,8 +4187,7 @@ phutil_register_library_map(array( 'PhabricatorConfigDictionarySource' => 'PhabricatorConfigSource', 'PhabricatorConfigEditController' => 'PhabricatorConfigController', 'PhabricatorConfigEditor' => 'PhabricatorApplicationTransactionEditor', - 'PhabricatorConfigEntry' => - array( + 'PhabricatorConfigEntry' => array( 0 => 'PhabricatorConfigEntryDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4254,8 +4206,7 @@ phutil_register_library_map(array( 'PhabricatorConfigManagementListWorkflow' => 'PhabricatorConfigManagementWorkflow', 'PhabricatorConfigManagementSetWorkflow' => 'PhabricatorConfigManagementWorkflow', 'PhabricatorConfigManagementWorkflow' => 'PhabricatorManagementWorkflow', - 'PhabricatorConfigOption' => - array( + 'PhabricatorConfigOption' => array( 0 => 'Phobject', 1 => 'PhabricatorMarkupInterface', ), @@ -4272,8 +4223,7 @@ phutil_register_library_map(array( 'PhabricatorController' => 'AphrontController', 'PhabricatorCookies' => 'Phobject', 'PhabricatorCoreConfigOptions' => 'PhabricatorApplicationConfigOptions', - 'PhabricatorCountdown' => - array( + 'PhabricatorCountdown' => array( 0 => 'PhabricatorCountdownDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4309,8 +4259,7 @@ phutil_register_library_map(array( 'PhabricatorDaemonController' => 'PhabricatorController', 'PhabricatorDaemonDAO' => 'PhabricatorLiskDAO', 'PhabricatorDaemonEventListener' => 'PhabricatorEventListener', - 'PhabricatorDaemonLog' => - array( + 'PhabricatorDaemonLog' => array( 0 => 'PhabricatorDaemonDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4333,8 +4282,7 @@ phutil_register_library_map(array( 'PhabricatorDaemonManagementStopWorkflow' => 'PhabricatorDaemonManagementWorkflow', 'PhabricatorDaemonManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorDaemonTaskGarbageCollector' => 'PhabricatorGarbageCollector', - 'PhabricatorDashboard' => - array( + 'PhabricatorDashboard' => array( 0 => 'PhabricatorDashboardDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4351,15 +4299,13 @@ phutil_register_library_map(array( 'PhabricatorDashboardMovePanelController' => 'PhabricatorDashboardController', 'PhabricatorDashboardPHIDTypeDashboard' => 'PhabricatorPHIDType', 'PhabricatorDashboardPHIDTypePanel' => 'PhabricatorPHIDType', - 'PhabricatorDashboardPanel' => - array( + 'PhabricatorDashboardPanel' => array( 0 => 'PhabricatorDashboardDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorCustomFieldInterface', ), 'PhabricatorDashboardPanelArchiveController' => 'PhabricatorDashboardController', - 'PhabricatorDashboardPanelCoreCustomField' => - array( + 'PhabricatorDashboardPanelCoreCustomField' => array( 0 => 'PhabricatorDashboardPanelCustomField', 1 => 'PhabricatorStandardCustomFieldInterface', ), @@ -4422,8 +4368,7 @@ phutil_register_library_map(array( 'PhabricatorEventType' => 'PhutilEventType', 'PhabricatorExampleEventListener' => 'PhabricatorEventListener', 'PhabricatorExtendingPhabricatorConfigOptions' => 'PhabricatorApplicationConfigOptions', - 'PhabricatorExternalAccount' => - array( + 'PhabricatorExternalAccount' => array( 0 => 'PhabricatorUserDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4469,8 +4414,7 @@ phutil_register_library_map(array( 'PhabricatorFeedStoryReference' => 'PhabricatorFeedDAO', 'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants', - 'PhabricatorFile' => - array( + 'PhabricatorFile' => array( 0 => 'PhabricatorFileDAO', 1 => 'PhabricatorTokenReceiverInterface', 2 => 'PhabricatorSubscribableInterface', @@ -4485,8 +4429,7 @@ phutil_register_library_map(array( 'PhabricatorFileDeleteController' => 'PhabricatorFileController', 'PhabricatorFileDropUploadController' => 'PhabricatorFileController', 'PhabricatorFileEditor' => 'PhabricatorApplicationTransactionEditor', - 'PhabricatorFileImageMacro' => - array( + 'PhabricatorFileImageMacro' => array( 0 => 'PhabricatorFileDAO', 1 => 'PhabricatorSubscribableInterface', 2 => 'PhabricatorApplicationTransactionInterface', @@ -4519,8 +4462,7 @@ phutil_register_library_map(array( 'PhabricatorFilesManagementPurgeWorkflow' => 'PhabricatorFilesManagementWorkflow', 'PhabricatorFilesManagementRebuildWorkflow' => 'PhabricatorFilesManagementWorkflow', 'PhabricatorFilesManagementWorkflow' => 'PhabricatorManagementWorkflow', - 'PhabricatorFlag' => - array( + 'PhabricatorFlag' => array( 0 => 'PhabricatorFlagDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4640,8 +4582,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase', 'PhabricatorMetaMTAMailTestCase' => 'PhabricatorTestCase', 'PhabricatorMetaMTAMailgunReceiveController' => 'PhabricatorMetaMTAController', - 'PhabricatorMetaMTAMailingList' => - array( + 'PhabricatorMetaMTAMailingList' => array( 0 => 'PhabricatorMetaMTADAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4656,8 +4597,7 @@ phutil_register_library_map(array( 'PhabricatorMustVerifyEmailController' => 'PhabricatorAuthController', 'PhabricatorMySQLConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorMySQLFileStorageEngine' => 'PhabricatorFileStorageEngine', - 'PhabricatorNamedQuery' => - array( + 'PhabricatorNamedQuery' => array( 0 => 'PhabricatorSearchDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4673,8 +4613,7 @@ phutil_register_library_map(array( 'PhabricatorNotificationStatusController' => 'PhabricatorNotificationController', 'PhabricatorNotificationStatusView' => 'AphrontTagView', 'PhabricatorNotificationTestController' => 'PhabricatorNotificationController', - 'PhabricatorOAuthClientAuthorization' => - array( + 'PhabricatorOAuthClientAuthorization' => array( 0 => 'PhabricatorOAuthServerDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4690,8 +4629,7 @@ phutil_register_library_map(array( 'PhabricatorOAuthServerAuthorizationCode' => 'PhabricatorOAuthServerDAO', 'PhabricatorOAuthServerAuthorizationsSettingsPanel' => 'PhabricatorSettingsPanel', 'PhabricatorOAuthServerCapabilityCreateClients' => 'PhabricatorPolicyCapability', - 'PhabricatorOAuthServerClient' => - array( + 'PhabricatorOAuthServerClient' => array( 0 => 'PhabricatorOAuthServerDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4720,8 +4658,7 @@ phutil_register_library_map(array( 'PhabricatorOwnersListController' => 'PhabricatorOwnersController', 'PhabricatorOwnersOwner' => 'PhabricatorOwnersDAO', 'PhabricatorOwnersPHIDTypePackage' => 'PhabricatorPHIDType', - 'PhabricatorOwnersPackage' => - array( + 'PhabricatorOwnersPackage' => array( 0 => 'PhabricatorOwnersDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4735,8 +4672,7 @@ phutil_register_library_map(array( 'PhabricatorPasswordHasher' => 'Phobject', 'PhabricatorPasswordHasherTestCase' => 'PhabricatorTestCase', 'PhabricatorPasswordHasherUnavailableException' => 'Exception', - 'PhabricatorPaste' => - array( + 'PhabricatorPaste' => array( 0 => 'PhabricatorPasteDAO', 1 => 'PhabricatorSubscribableInterface', 2 => 'PhabricatorTokenReceiverInterface', @@ -4793,8 +4729,7 @@ phutil_register_library_map(array( 'PhabricatorPhrequentConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorPhrictionConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorPolicies' => 'PhabricatorPolicyConstants', - 'PhabricatorPolicy' => - array( + 'PhabricatorPolicy' => array( 0 => 'PhabricatorPolicyDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4825,8 +4760,7 @@ phutil_register_library_map(array( 'PhabricatorPolicyTestCase' => 'PhabricatorTestCase', 'PhabricatorPolicyTestObject' => 'PhabricatorPolicyInterface', 'PhabricatorPolicyType' => 'PhabricatorPolicyConstants', - 'PhabricatorProject' => - array( + 'PhabricatorProject' => array( 0 => 'PhabricatorProjectDAO', 1 => 'PhabricatorFlaggableInterface', 2 => 'PhabricatorPolicyInterface', @@ -4840,8 +4774,7 @@ phutil_register_library_map(array( 'PhabricatorProjectBoardEditController' => 'PhabricatorProjectBoardController', 'PhabricatorProjectBoardReorderController' => 'PhabricatorProjectBoardController', 'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController', - 'PhabricatorProjectColumn' => - array( + 'PhabricatorProjectColumn' => array( 0 => 'PhabricatorProjectDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorDestructableInterface', @@ -4852,8 +4785,7 @@ phutil_register_library_map(array( 'PhabricatorProjectColumnTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorProjectColumnTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhabricatorProjectConfigOptions' => 'PhabricatorApplicationConfigOptions', - 'PhabricatorProjectConfiguredCustomField' => - array( + 'PhabricatorProjectConfiguredCustomField' => array( 0 => 'PhabricatorProjectStandardCustomField', 1 => 'PhabricatorStandardCustomFieldInterface', ), @@ -4884,8 +4816,7 @@ phutil_register_library_map(array( 'PhabricatorProjectSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorProjectSlug' => 'PhabricatorProjectDAO', - 'PhabricatorProjectStandardCustomField' => - array( + 'PhabricatorProjectStandardCustomField' => array( 0 => 'PhabricatorProjectCustomField', 1 => 'PhabricatorStandardCustomFieldInterface', ), @@ -4914,8 +4845,7 @@ phutil_register_library_map(array( 'PhabricatorRemarkupRuleMention' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRuleObject' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRuleYoutube' => 'PhutilRemarkupRule', - 'PhabricatorRepository' => - array( + 'PhabricatorRepository' => array( 0 => 'PhabricatorRepositoryDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorFlaggableInterface', @@ -4923,8 +4853,7 @@ phutil_register_library_map(array( 4 => 'PhabricatorDestructableInterface', 5 => 'PhabricatorProjectInterface', ), - 'PhabricatorRepositoryArcanistProject' => - array( + 'PhabricatorRepositoryArcanistProject' => array( 0 => 'PhabricatorRepositoryDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorDestructableInterface', @@ -4932,14 +4861,12 @@ phutil_register_library_map(array( 'PhabricatorRepositoryArcanistProjectDeleteController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryArcanistProjectEditController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryArcanistProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'PhabricatorRepositoryAuditRequest' => - array( + 'PhabricatorRepositoryAuditRequest' => array( 0 => 'PhabricatorRepositoryDAO', 1 => 'PhabricatorPolicyInterface', ), 'PhabricatorRepositoryBranch' => 'PhabricatorRepositoryDAO', - 'PhabricatorRepositoryCommit' => - array( + 'PhabricatorRepositoryCommit' => array( 0 => 'PhabricatorRepositoryDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorFlaggableInterface', @@ -4978,8 +4905,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoryManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker', 'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker', - 'PhabricatorRepositoryMirror' => - array( + 'PhabricatorRepositoryMirror' => array( 0 => 'PhabricatorRepositoryDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -4994,14 +4920,12 @@ phutil_register_library_map(array( 'PhabricatorRepositoryParsedChange' => 'Phobject', 'PhabricatorRepositoryPullEngine' => 'PhabricatorRepositoryEngine', 'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon', - 'PhabricatorRepositoryPushEvent' => - array( + 'PhabricatorRepositoryPushEvent' => array( 0 => 'PhabricatorRepositoryDAO', 1 => 'PhabricatorPolicyInterface', ), 'PhabricatorRepositoryPushEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'PhabricatorRepositoryPushLog' => - array( + 'PhabricatorRepositoryPushLog' => array( 0 => 'PhabricatorRepositoryDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5010,8 +4934,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoryPushMailWorker' => 'PhabricatorWorker', 'PhabricatorRepositoryPushReplyHandler' => 'PhabricatorMailReplyHandler', 'PhabricatorRepositoryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'PhabricatorRepositoryRefCursor' => - array( + 'PhabricatorRepositoryRefCursor' => array( 0 => 'PhabricatorRepositoryDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5047,8 +4970,7 @@ phutil_register_library_map(array( 'PhabricatorSSHLog' => 'Phobject', 'PhabricatorSSHPassthruCommand' => 'Phobject', 'PhabricatorSSHWorkflow' => 'PhabricatorManagementWorkflow', - 'PhabricatorSavedQuery' => - array( + 'PhabricatorSavedQuery' => array( 0 => 'PhabricatorSearchDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5131,8 +5053,7 @@ phutil_register_library_map(array( 'PhabricatorSlowvoteListController' => 'PhabricatorSlowvoteController', 'PhabricatorSlowvoteOption' => 'PhabricatorSlowvoteDAO', 'PhabricatorSlowvotePHIDTypePoll' => 'PhabricatorPHIDType', - 'PhabricatorSlowvotePoll' => - array( + 'PhabricatorSlowvotePoll' => array( 0 => 'PhabricatorSlowvoteDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorSubscribableInterface', @@ -5196,8 +5117,7 @@ phutil_register_library_map(array( 'PhabricatorTestStorageEngine' => 'PhabricatorFileStorageEngine', 'PhabricatorTestWorker' => 'PhabricatorWorker', 'PhabricatorTimeTestCase' => 'PhabricatorTestCase', - 'PhabricatorToken' => - array( + 'PhabricatorToken' => array( 0 => 'PhabricatorTokenDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5206,8 +5126,7 @@ phutil_register_library_map(array( 'PhabricatorTokenCountQuery' => 'PhabricatorOffsetPagedQuery', 'PhabricatorTokenDAO' => 'PhabricatorLiskDAO', 'PhabricatorTokenGiveController' => 'PhabricatorTokenController', - 'PhabricatorTokenGiven' => - array( + 'PhabricatorTokenGiven' => array( 0 => 'PhabricatorTokenDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5240,8 +5159,7 @@ phutil_register_library_map(array( 'PhabricatorUIStatusExample' => 'PhabricatorUIExample', 'PhabricatorUITooltipExample' => 'PhabricatorUIExample', 'PhabricatorUnitsTestCase' => 'PhabricatorTestCase', - 'PhabricatorUser' => - array( + 'PhabricatorUser' => array( 0 => 'PhabricatorUserDAO', 1 => 'PhutilPerson', 2 => 'PhabricatorPolicyInterface', @@ -5250,8 +5168,7 @@ phutil_register_library_map(array( ), 'PhabricatorUserBlurbField' => 'PhabricatorUserCustomField', 'PhabricatorUserConfigOptions' => 'PhabricatorApplicationConfigOptions', - 'PhabricatorUserConfiguredCustomField' => - array( + 'PhabricatorUserConfiguredCustomField' => array( 0 => 'PhabricatorUserCustomField', 1 => 'PhabricatorStandardCustomFieldInterface', ), @@ -5264,8 +5181,7 @@ phutil_register_library_map(array( 'PhabricatorUserEditorTestCase' => 'PhabricatorTestCase', 'PhabricatorUserEmail' => 'PhabricatorUserDAO', 'PhabricatorUserEmailTestCase' => 'PhabricatorTestCase', - 'PhabricatorUserLog' => - array( + 'PhabricatorUserLog' => array( 0 => 'PhabricatorUserDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5317,8 +5233,7 @@ phutil_register_library_map(array( 'PhabricatorXHProfSampleListController' => 'PhabricatorXHProfController', 'PhameBasicBlogSkin' => 'PhameBlogSkin', 'PhameBasicTemplateBlogSkin' => 'PhameBasicBlogSkin', - 'PhameBlog' => - array( + 'PhameBlog' => array( 0 => 'PhameDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorMarkupInterface', @@ -5334,8 +5249,7 @@ phutil_register_library_map(array( 'PhameCelerityResources' => 'CelerityResources', 'PhameController' => 'PhabricatorController', 'PhameDAO' => 'PhabricatorLiskDAO', - 'PhamePost' => - array( + 'PhamePost' => array( 0 => 'PhameDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorMarkupInterface', @@ -5361,8 +5275,7 @@ phutil_register_library_map(array( 'PhluxPHIDTypeVariable' => 'PhabricatorPHIDType', 'PhluxTransaction' => 'PhabricatorApplicationTransaction', 'PhluxTransactionQuery' => 'PhabricatorApplicationTransactionQuery', - 'PhluxVariable' => - array( + 'PhluxVariable' => array( 0 => 'PhluxDAO', 1 => 'PhabricatorFlaggableInterface', 2 => 'PhabricatorPolicyInterface', @@ -5375,8 +5288,7 @@ phutil_register_library_map(array( 'PholioCapabilityDefaultView' => 'PhabricatorPolicyCapability', 'PholioController' => 'PhabricatorController', 'PholioDAO' => 'PhabricatorLiskDAO', - 'PholioImage' => - array( + 'PholioImage' => array( 0 => 'PholioDAO', 1 => 'PhabricatorMarkupInterface', 2 => 'PhabricatorPolicyInterface', @@ -5386,8 +5298,7 @@ phutil_register_library_map(array( 'PholioInlineController' => 'PholioController', 'PholioInlineListController' => 'PholioController', 'PholioInlineThumbController' => 'PholioController', - 'PholioMock' => - array( + 'PholioMock' => array( 0 => 'PholioDAO', 1 => 'PhabricatorMarkupInterface', 2 => 'PhabricatorPolicyInterface', @@ -5420,8 +5331,7 @@ phutil_register_library_map(array( 'PholioTransactionType' => 'PholioConstants', 'PholioTransactionView' => 'PhabricatorApplicationTransactionView', 'PholioUploadedImageView' => 'AphrontView', - 'PhortuneAccount' => - array( + 'PhortuneAccount' => array( 0 => 'PhortuneDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5443,8 +5353,7 @@ phutil_register_library_map(array( 'PhortuneMultiplePaymentProvidersException' => 'Exception', 'PhortuneNoPaymentProviderException' => 'Exception', 'PhortuneNotImplementedException' => 'Exception', - 'PhortunePaymentMethod' => - array( + 'PhortunePaymentMethod' => array( 0 => 'PhortuneDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5454,8 +5363,7 @@ phutil_register_library_map(array( 'PhortunePaymentMethodViewController' => 'PhabricatorController', 'PhortunePaymentProviderTestCase' => 'PhabricatorTestCase', 'PhortunePaypalPaymentProvider' => 'PhortunePaymentProvider', - 'PhortuneProduct' => - array( + 'PhortuneProduct' => array( 0 => 'PhortuneDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5477,14 +5385,12 @@ phutil_register_library_map(array( 'PhragmentController' => 'PhabricatorController', 'PhragmentCreateController' => 'PhragmentController', 'PhragmentDAO' => 'PhabricatorLiskDAO', - 'PhragmentFragment' => - array( + 'PhragmentFragment' => array( 0 => 'PhragmentDAO', 1 => 'PhabricatorPolicyInterface', ), 'PhragmentFragmentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'PhragmentFragmentVersion' => - array( + 'PhragmentFragmentVersion' => array( 0 => 'PhragmentDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5497,13 +5403,11 @@ phutil_register_library_map(array( 'PhragmentPatchUtil' => 'Phobject', 'PhragmentPolicyController' => 'PhragmentController', 'PhragmentRevertController' => 'PhragmentController', - 'PhragmentSnapshot' => - array( + 'PhragmentSnapshot' => array( 0 => 'PhragmentDAO', 1 => 'PhabricatorPolicyInterface', ), - 'PhragmentSnapshotChild' => - array( + 'PhragmentSnapshotChild' => array( 0 => 'PhragmentDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5526,8 +5430,7 @@ phutil_register_library_map(array( 'PhrequentTrackController' => 'PhrequentController', 'PhrequentTrackingEditor' => 'PhabricatorEditor', 'PhrequentUIEventListener' => 'PhabricatorEventListener', - 'PhrequentUserTime' => - array( + 'PhrequentUserTime' => array( 0 => 'PhrequentDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5535,8 +5438,7 @@ phutil_register_library_map(array( 'PhrictionActionConstants' => 'PhrictionConstants', 'PhrictionActionMenuEventListener' => 'PhabricatorEventListener', 'PhrictionChangeType' => 'PhrictionConstants', - 'PhrictionContent' => - array( + 'PhrictionContent' => array( 0 => 'PhrictionDAO', 1 => 'PhabricatorMarkupInterface', ), @@ -5544,8 +5446,7 @@ phutil_register_library_map(array( 'PhrictionDAO' => 'PhabricatorLiskDAO', 'PhrictionDeleteController' => 'PhrictionController', 'PhrictionDiffController' => 'PhrictionController', - 'PhrictionDocument' => - array( + 'PhrictionDocument' => array( 0 => 'PhrictionDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorSubscribableInterface', @@ -5568,8 +5469,7 @@ phutil_register_library_map(array( 'PhrictionSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhrictionSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PonderAddAnswerView' => 'AphrontView', - 'PonderAnswer' => - array( + 'PonderAnswer' => array( 0 => 'PonderDAO', 1 => 'PhabricatorMarkupInterface', 2 => 'PonderVotableInterface', @@ -5587,8 +5487,7 @@ phutil_register_library_map(array( 'PonderAnswerTransaction' => 'PhabricatorApplicationTransaction', 'PonderAnswerTransactionComment' => 'PhabricatorApplicationTransactionComment', 'PonderAnswerTransactionQuery' => 'PhabricatorApplicationTransactionQuery', - 'PonderComment' => - array( + 'PonderComment' => array( 0 => 'PonderDAO', 1 => 'PhabricatorMarkupInterface', ), @@ -5598,8 +5497,7 @@ phutil_register_library_map(array( 'PonderEditor' => 'PhabricatorApplicationTransactionEditor', 'PonderPHIDTypeAnswer' => 'PhabricatorPHIDType', 'PonderPHIDTypeQuestion' => 'PhabricatorPHIDType', - 'PonderQuestion' => - array( + 'PonderQuestion' => array( 0 => 'PonderDAO', 1 => 'PhabricatorMarkupInterface', 2 => 'PonderVotableInterface', @@ -5635,8 +5533,7 @@ phutil_register_library_map(array( 'ProjectRemarkupRule' => 'PhabricatorRemarkupRuleObject', 'QueryFormattingTestCase' => 'PhabricatorTestCase', 'ReleephAuthorFieldSpecification' => 'ReleephFieldSpecification', - 'ReleephBranch' => - array( + 'ReleephBranch' => array( 0 => 'ReleephDAO', 1 => 'PhabricatorPolicyInterface', ), @@ -5653,8 +5550,7 @@ phutil_register_library_map(array( 'ReleephBranchSearchEngine' => 'PhabricatorApplicationSearchEngine', 'ReleephBranchTransaction' => 'PhabricatorApplicationTransaction', 'ReleephBranchTransactionQuery' => 'PhabricatorApplicationTransactionQuery', - 'ReleephBranchViewController' => - array( + 'ReleephBranchViewController' => array( 0 => 'ReleephBranchController', 1 => 'PhabricatorApplicationSearchResultsControllerInterface', ), @@ -5668,8 +5564,7 @@ phutil_register_library_map(array( 'ReleephDiffMessageFieldSpecification' => 'ReleephFieldSpecification', 'ReleephDiffSizeFieldSpecification' => 'ReleephFieldSpecification', 'ReleephFieldParseException' => 'Exception', - 'ReleephFieldSpecification' => - array( + 'ReleephFieldSpecification' => array( 0 => 'PhabricatorCustomField', 1 => 'PhabricatorMarkupInterface', ), @@ -5690,19 +5585,16 @@ phutil_register_library_map(array( 'ReleephProductSearchEngine' => 'PhabricatorApplicationSearchEngine', 'ReleephProductTransaction' => 'PhabricatorApplicationTransaction', 'ReleephProductTransactionQuery' => 'PhabricatorApplicationTransactionQuery', - 'ReleephProductViewController' => - array( + 'ReleephProductViewController' => array( 0 => 'ReleephProductController', 1 => 'PhabricatorApplicationSearchResultsControllerInterface', ), - 'ReleephProject' => - array( + 'ReleephProject' => array( 0 => 'ReleephDAO', 1 => 'PhabricatorPolicyInterface', ), 'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification', - 'ReleephRequest' => - array( + 'ReleephRequest' => array( 0 => 'ReleephDAO', 1 => 'PhabricatorPolicyInterface', 2 => 'PhabricatorCustomFieldInterface', diff --git a/src/applications/feed/PhabricatorFeedStoryPublisher.php b/src/applications/feed/PhabricatorFeedStoryPublisher.php index fbbeee48a0..9770c89db9 100644 --- a/src/applications/feed/PhabricatorFeedStoryPublisher.php +++ b/src/applications/feed/PhabricatorFeedStoryPublisher.php @@ -176,7 +176,7 @@ final class PhabricatorFeedStoryPublisher { $data = array( 'key' => (string)$chrono_key, 'type' => 'notification', - 'subscribers' => $this->subscribedPHIDs, + 'subscribers' => array_values($this->subscribedPHIDs), ); PhabricatorNotificationClient::tryToPostMessage($data); diff --git a/support/aphlict/server/aphlict_server.js b/support/aphlict/server/aphlict_server.js index d2594c720e..f0bc7b854c 100644 --- a/support/aphlict/server/aphlict_server.js +++ b/support/aphlict/server/aphlict_server.js @@ -180,6 +180,10 @@ var receive_server = http.createServer(function(request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); } catch (err) { + debug.log( + '<%s> Bad Request! %s', + request.socket.remoteAddress, + err); response.statusCode = 400; response.write('400 Bad Request'); } finally { From ca83e4c6a8642290713b40ca43653e04ebc2c54d Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 14:49:11 -0700 Subject: [PATCH 03/44] Adjust Phriction remarkup rule priority Summary: Fixes T5645. See D9964. Test Plan: Accurate link for `[[ xyz | T25 ]]`. Here are the priorities: ``` 0 PhutilRemarkupRuleEscapeRemarkup 100 PhutilRemarkupRuleMonospace 150 PhutilRemarkupRuleDocumentLink 175 PhrictionRemarkupRule 200 HarbormasterRemarkupRule 200 PhabricatorRemarkupRuleEmbedFile 200 DivinerRemarkupRuleSymbol 200 PhabricatorCountdownRemarkupRule 200 LegalpadDocumentRemarkupRule 200 PhabricatorRemarkupRuleMeme 200 PassphraseRemarkupRule 200 PhabricatorRemarkupRuleIcon 200 SlowvoteRemarkupRule 200 HeraldRemarkupRule 200 PhabricatorPasteRemarkupRule 200 ProjectRemarkupRule 200 DiffusionCommitRemarkupRule 200 DiffusionRepositoryRemarkupRule 200 DifferentialRemarkupRule 200 PonderRemarkupRule 200 ManiphestRemarkupRule 200 PhabricatorDashboardRemarkupRule 200 PholioRemarkupRule 350 PhabricatorRemarkupRuleYoutube 350 DoorkeeperRemarkupRuleAsana 350 DoorkeeperRemarkupRuleJIRA 400 PhutilRemarkupRuleHyperlink 500 CustomInlineCodeRule 500 CustomInlineJIRA5Rule 500 PhabricatorRemarkupRuleImageMacro 500 PhabricatorRemarkupRuleMention 1000 PhutilRemarkupRuleBold 1000 PhutilRemarkupRuleUnderline 1000 PhutilRemarkupRuleDel 1000 PhutilRemarkupRuleItalic ``` Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5645 Differential Revision: https://secure.phabricator.com/D9965 --- src/applications/phriction/remarkup/PhrictionRemarkupRule.php | 2 +- src/infrastructure/markup/PhabricatorMarkupEngine.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/applications/phriction/remarkup/PhrictionRemarkupRule.php b/src/applications/phriction/remarkup/PhrictionRemarkupRule.php index b8f61b2c02..48eb9cc3ee 100644 --- a/src/applications/phriction/remarkup/PhrictionRemarkupRule.php +++ b/src/applications/phriction/remarkup/PhrictionRemarkupRule.php @@ -3,7 +3,7 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule { public function getPriority() { - return 350.0; + return 175.0; } public function apply($text) { diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php index df7fa0c887..aa89e6ea07 100644 --- a/src/infrastructure/markup/PhabricatorMarkupEngine.php +++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php @@ -41,7 +41,7 @@ final class PhabricatorMarkupEngine { private $objects = array(); private $viewer; - private $version = 12; + private $version = 13; /* -( Markup Pipeline )---------------------------------------------------- */ From 7deec8208ff9bc57eb7a77b0d74850aadd79ed4f Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:40:19 -0700 Subject: [PATCH 04/44] Make Maniphest project edits more transaction-oriented Summary: Ref T5245. Currently, task/project links rely on side effects in `save()`. Make them more transaction-oriented, with the goal of moving fully to edges a few diffs down the line. Test Plan: - Added and removed projects using "Edit Task", "Associate Projects" comment action, and Herald. - Verified database ended up in the expected state. Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9833 --- .../editor/ManiphestTransactionEditor.php | 30 ++++++++++--------- .../maniphest/storage/ManiphestTask.php | 9 ------ 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index 9eda17b7ee..a8c69cba24 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -152,7 +152,9 @@ final class ManiphestTransactionEditor case ManiphestTransaction::TYPE_CCS: return $object->setCCPHIDs($xaction->getNewValue()); case ManiphestTransaction::TYPE_PROJECTS: - return $object->setProjectPHIDs($xaction->getNewValue()); + $object->setProjectPHIDs($xaction->getNewValue()); + ManiphestTaskProject::updateTaskProjects($object); + return $object; case ManiphestTransaction::TYPE_EDGE: // These are a weird, funky mess and are already being applied by the // time we reach this. @@ -415,19 +417,6 @@ final class ManiphestTransactionEditor $existing_cc = $object->getCCPHIDs(); $new_cc = array_unique(array_merge($cc_phids, $existing_cc)); $object->setCCPHIDs($new_cc); - $save_again = true; - } - - $project_phids = $adapter->getProjectPHIDs(); - if ($project_phids) { - $existing_projects = $object->getProjectPHIDs(); - $new_projects = array_unique( - array_merge($project_phids, $existing_projects)); - $object->setProjectPHIDs($new_projects); - $save_again = true; - } - - if ($save_again) { $object->save(); } @@ -442,6 +431,19 @@ final class ManiphestTransactionEditor ->setNewValue($assign_phid); } + $project_phids = $adapter->getProjectPHIDs(); + if ($project_phids) { + $existing_projects = $object->getProjectPHIDs(); + $new_projects = array_unique( + array_merge( + $project_phids, + $existing_projects)); + + $xactions[] = id(new ManiphestTransaction()) + ->setTransactionType(ManiphestTransaction::TYPE_PROJECTS) + ->setNewValue($new_projects); + } + return $xactions; } diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index 9477f6af7c..2a88ba9864 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -30,7 +30,6 @@ final class ManiphestTask extends ManiphestDAO protected $attached = array(); protected $projectPHIDs = array(); - private $projectsNeedUpdate; private $subscribersNeedUpdate; protected $ownerOrdering; @@ -92,7 +91,6 @@ final class ManiphestTask extends ManiphestDAO public function setProjectPHIDs(array $phids) { $this->projectPHIDs = array_values($phids); - $this->projectsNeedUpdate = true; return $this; } @@ -140,13 +138,6 @@ final class ManiphestTask extends ManiphestDAO $result = parent::save(); - if ($this->projectsNeedUpdate) { - // If we've changed the project PHIDs for this task, update the link - // table. - ManiphestTaskProject::updateTaskProjects($this); - $this->projectsNeedUpdate = false; - } - if ($this->subscribersNeedUpdate) { // If we've changed the subscriber PHIDs for this task, update the link // table. From 7afb770cbe07bed15399c6daf4d28d61d54b44cc Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:40:37 -0700 Subject: [PATCH 05/44] Make edge types modular Summary: Ref T5245. I want to add a new capability to edge types, which is a good opportunity to move away from `PhabricatorEdgeConfig`, which isn't modular. This is basically the same as the modularization of PHID types, which has worked well. Add `PhabricatorEdgeType` and provide an adaption layer for the existing code. This has no runtime changes, except the fixed edge constant. Test Plan: Ran `var_dump(PhabricatorEdgeType::getAllTypes())` and got reasonable looking output. Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9837 --- src/__phutil_library_map__.php | 4 + .../edges/constants/PhabricatorEdgeConfig.php | 50 +++- .../edges/type/PhabricatorEdgeType.php | 230 ++++++++++++++++++ .../edges/type/PhabricatorLegacyEdgeType.php | 119 +++++++++ 4 files changed, 402 insertions(+), 1 deletion(-) create mode 100644 src/infrastructure/edges/type/PhabricatorEdgeType.php create mode 100644 src/infrastructure/edges/type/PhabricatorLegacyEdgeType.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3262902c02..39eb658120 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1562,6 +1562,7 @@ phutil_register_library_map(array( 'PhabricatorEdgeGraph' => 'infrastructure/edges/util/PhabricatorEdgeGraph.php', 'PhabricatorEdgeQuery' => 'infrastructure/edges/query/PhabricatorEdgeQuery.php', 'PhabricatorEdgeTestCase' => 'infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php', + 'PhabricatorEdgeType' => 'infrastructure/edges/type/PhabricatorEdgeType.php', 'PhabricatorEditor' => 'infrastructure/PhabricatorEditor.php', 'PhabricatorEmailLoginController' => 'applications/auth/controller/PhabricatorEmailLoginController.php', 'PhabricatorEmailVerificationController' => 'applications/auth/controller/PhabricatorEmailVerificationController.php', @@ -1712,6 +1713,7 @@ phutil_register_library_map(array( 'PhabricatorJavelinLinter' => 'infrastructure/lint/linter/PhabricatorJavelinLinter.php', 'PhabricatorJumpNavHandler' => 'applications/search/engine/PhabricatorJumpNavHandler.php', 'PhabricatorKeyValueDatabaseCache' => 'applications/cache/PhabricatorKeyValueDatabaseCache.php', + 'PhabricatorLegacyEdgeType' => 'infrastructure/edges/type/PhabricatorLegacyEdgeType.php', 'PhabricatorLegalpadConfigOptions' => 'applications/legalpad/config/PhabricatorLegalpadConfigOptions.php', 'PhabricatorLegalpadPHIDTypeDocument' => 'applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php', 'PhabricatorLipsumArtist' => 'applications/lipsum/image/PhabricatorLipsumArtist.php', @@ -4356,6 +4358,7 @@ phutil_register_library_map(array( 'PhabricatorEdgeGraph' => 'AbstractDirectedGraph', 'PhabricatorEdgeQuery' => 'PhabricatorQuery', 'PhabricatorEdgeTestCase' => 'PhabricatorTestCase', + 'PhabricatorEdgeType' => 'Phobject', 'PhabricatorEditor' => 'Phobject', 'PhabricatorEmailLoginController' => 'PhabricatorAuthController', 'PhabricatorEmailVerificationController' => 'PhabricatorAuthController', @@ -4509,6 +4512,7 @@ phutil_register_library_map(array( 'PhabricatorIteratedMD5PasswordHasher' => 'PhabricatorPasswordHasher', 'PhabricatorJavelinLinter' => 'ArcanistLinter', 'PhabricatorKeyValueDatabaseCache' => 'PhutilKeyValueCache', + 'PhabricatorLegacyEdgeType' => 'PhabricatorEdgeType', 'PhabricatorLegalpadConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorLegalpadPHIDTypeDocument' => 'PhabricatorPHIDType', 'PhabricatorLipsumGenerateWorkflow' => 'PhabricatorLipsumManagementWorkflow', diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index d670107ccc..eb951356c4 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -78,6 +78,13 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { const TYPE_OBJECT_NEEDS_SIGNATURE = 49; const TYPE_SIGNATURE_NEEDED_BY_OBJECT = 50; +/* !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! */ + + // HEY! DO NOT ADD NEW CONSTANTS HERE! + // Instead, subclass PhabricatorEdgeType. + +/* !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! STOP !!!! */ + const TYPE_TEST_NO_CYCLE = 9000; const TYPE_PHOB_HAS_ASANATASK = 80001; @@ -89,6 +96,47 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { const TYPE_PHOB_HAS_JIRAISSUE = 80004; const TYPE_JIRAISSUE_HAS_PHOB = 80005; + + /** + * Build @{class:PhabricatorLegacyEdgeType} objects for edges which have not + * yet been modernized. This allows code to act as though we've completed + * the edge type migration before we actually do all the work, by building + * these fake type objects. + * + * @param list List of edge types that objects should not be built for. + * This is used to avoid constructing duplicate objects for edge constants + * which have migrated and already have a real object. + * @return list Real-looking edge type objects for + * unmigrated edge types. + */ + public static function getLegacyTypes(array $exclude) { + $consts = array_merge( + range(1, 50), + array(9000), + range(80000, 80005)); + $consts = array_diff($consts, $exclude); + + $map = array(); + foreach ($consts as $const) { + $prevent_cycles = self::shouldPreventCycles($const); + $inverse_constant = self::getInverse($const); + + $map[$const] = id(new PhabricatorLegacyEdgeType()) + ->setEdgeConstant($const) + ->setShouldPreventCycles($prevent_cycles) + ->setInverseEdgeConstant($inverse_constant) + ->setStrings( + array( + self::getAddStringForEdgeType($const), + self::getRemoveStringForEdgeType($const), + self::getEditStringForEdgeType($const), + self::getFeedStringForEdgeType($const), + )); + } + + return $map; + } + public static function getInverse($edge_type) { static $map = array( self::TYPE_TASK_HAS_COMMIT => self::TYPE_COMMIT_HAS_TASK, @@ -136,7 +184,7 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { self::TYPE_DREV_HAS_COMMIT => self::TYPE_COMMIT_HAS_DREV, self::TYPE_COMMIT_HAS_DREV => self::TYPE_DREV_HAS_COMMIT, - self::TYPE_OBJECT_HAS_CONTRIBUTOR => self::TYPE_SUBSCRIBED_TO_OBJECT, + self::TYPE_OBJECT_HAS_CONTRIBUTOR => self::TYPE_CONTRIBUTED_TO_OBJECT, self::TYPE_CONTRIBUTED_TO_OBJECT => self::TYPE_OBJECT_HAS_CONTRIBUTOR, self::TYPE_TASK_HAS_MOCK => self::TYPE_MOCK_HAS_TASK, diff --git a/src/infrastructure/edges/type/PhabricatorEdgeType.php b/src/infrastructure/edges/type/PhabricatorEdgeType.php new file mode 100644 index 0000000000..f26bac0be2 --- /dev/null +++ b/src/infrastructure/edges/type/PhabricatorEdgeType.php @@ -0,0 +1,230 @@ +getConstant('EDGECONST'); + if ($const === false) { + throw new Exception( + pht( + 'EdgeType class "%s" must define an EDGECONST property.', + get_class($this))); + } + + if (!is_int($const) || ($const <= 0)) { + throw new Exception( + pht( + 'EdgeType class "%s" has an invalid EDGECONST property. Edge '. + 'constants must be positive integers.', + get_class($this))); + } + + return $const; + } + + public function getInverseEdgeConstant() { + return null; + } + + public function shouldPreventCycles() { + return false; + } + + public function getTransactionAddString( + $actor, + $add_count, + $add_edges) { + + return pht( + '%s added %s edge(s): %s.', + $actor, + $add_count, + $add_edges); + } + + public function getTransactionRemoveString( + $actor, + $rem_count, + $rem_edges) { + + return pht( + '%s removed %s edge(s): %s.', + $actor, + $rem_count, + $rem_edges); + } + + public function getTransactionEditString( + $actor, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges) { + + return pht( + '%s edited %s edge(s), added %s: %s; removed %s: %s.', + $actor, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges); + } + + public function getFeedAddString( + $actor, + $object, + $add_count, + $add_edges) { + + return pht( + '%s added %s edge(s) to %s: %s.', + $actor, + $add_count, + $object, + $add_edges); + } + + public function getFeedRemoveString( + $actor, + $object, + $rem_count, + $rem_edges) { + + return pht( + '%s removed %s edge(s) from %s: %s.', + $actor, + $rem_count, + $object, + $rem_edges); + } + + public function getFeedEditString( + $actor, + $object, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges) { + + return pht( + '%s edited %s edge(s) for %s, added %s: %s; removed %s: %s.', + $actor, + $total_count, + $object, + $add_count, + $add_edges, + $rem_count, + $rem_edges); + } + + +/* -( Loading Types )------------------------------------------------------ */ + + + /** + * @task load + */ + public static function getAllTypes() { + static $type_map; + + if ($type_map === null) { + $types = id(new PhutilSymbolLoader()) + ->setAncestorClass(__CLASS__) + ->loadObjects(); + + $map = array(); + + + // TODO: Remove this once everything is migrated. + $exclude = mpull($types, 'getEdgeConstant'); + $map = PhabricatorEdgeConfig::getLegacyTypes($exclude); + unset($types['PhabricatorLegacyEdgeType']); + + + foreach ($types as $class => $type) { + $const = $type->getEdgeConstant(); + + if (isset($map[$const])) { + throw new Exception( + pht( + 'Two edge types ("%s", "%s") share the same edge constant '. + '(%d). Each edge type must have a unique constant.', + $class, + get_class($map[$const]), + $const)); + } + + $map[$const] = $type; + } + + // Check that all the inverse edge definitions actually make sense. If + // edge type A says B is its inverse, B must exist and say that A is its + // inverse. + + foreach ($map as $const => $type) { + $inverse = $type->getInverseEdgeConstant(); + if ($inverse === null) { + continue; + } + + if (empty($map[$inverse])) { + throw new Exception( + pht( + 'Edge type "%s" ("%d") defines an inverse type ("%d") which '. + 'does not exist.', + get_class($type), + $const, + $inverse)); + } + + $inverse_inverse = $map[$inverse]->getInverseEdgeConstant(); + if ($inverse_inverse !== $const) { + throw new Exception( + pht( + 'Edge type "%s" ("%d") defines an inverse type ("%d"), but that '. + 'inverse type defines a different type ("%d") as its '. + 'inverse.', + get_class($type), + $const, + $inverse, + $inverse_inverse)); + } + } + + $type_map = $map; + } + + return $type_map; + } + + + /** + * @task load + */ + public static function getByConstant($const) { + $type = idx(self::getAllTypes(), $const); + + if (!$type) { + throw new Exception( + pht('Unknown edge constant "%s"!', $const)); + } + + return $type; + } + +} diff --git a/src/infrastructure/edges/type/PhabricatorLegacyEdgeType.php b/src/infrastructure/edges/type/PhabricatorLegacyEdgeType.php new file mode 100644 index 0000000000..2147108acd --- /dev/null +++ b/src/infrastructure/edges/type/PhabricatorLegacyEdgeType.php @@ -0,0 +1,119 @@ +edgeConstant; + } + + public function getInverseEdgeConstant() { + return $this->inverseEdgeConstant; + } + + public function shouldPreventCycles() { + return $this->shouldPreventCycles; + } + + public function setEdgeConstant($edge_constant) { + $this->edgeConstant = $edge_constant; + return $this; + } + + public function setInverseEdgeConstant($inverse_edge_constant) { + $this->inverseEdgeConstant = $inverse_edge_constant; + return $this; + } + + public function setShouldPreventCycles($should_prevent_cycles) { + $this->shouldPreventCycles = $should_prevent_cycles; + return $this; + } + + public function setStrings(array $strings) { + $this->strings = $strings; + return $this; + } + + private function getString($idx, array $argv) { + array_unshift($argv, idx($this->strings, $idx, '')); + + // TODO: Burn this class in a fire. Just hiding this from lint for now. + $pht_func = 'pht'; + return call_user_func_array($pht_func, $argv); + } + + public function getTransactionAddString( + $actor, + $add_count, + $add_edges) { + + $args = func_get_args(); + return $this->getString(0, $args); + } + + public function getTransactionRemoveString( + $actor, + $rem_count, + $rem_edges) { + + $args = func_get_args(); + return $this->getString(1, $args); + } + + public function getTransactionEditString( + $actor, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges) { + + $args = func_get_args(); + return $this->getString(2, $args); + } + + public function getFeedAddString( + $actor, + $object, + $add_count, + $add_edges) { + + $args = func_get_args(); + return $this->getString(3, $args); + } + + public function getFeedRemoveString( + $actor, + $object, + $rem_count, + $rem_edges) { + + $args = func_get_args(); + return $this->getString(3, $args); + } + + public function getFeedEditString( + $actor, + $object, + $total_count, + $add_count, + $add_edges, + $rem_count, + $rem_edges) { + + $args = func_get_args(); + return $this->getString(3, $args); + } + +} From ace1feb70220a589386d0fa7fd9163998e13f631 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:40:52 -0700 Subject: [PATCH 06/44] Implement PhabricatorApplicationTransactionInterface on ManiphestTask Summary: Ref T5245. A very long time ago I had this terrible idea that we'd let objects react to edges being added and insert transactions in response. This turned out to be a clearly bad idea very quickly, for like 15 different reasons. A big issue is that it inverts the responsibilities of editors. It's also just clumsy and messy. We now have `PhabricatorApplicationTransactionInterface` instead, which mostly provides a cleaner way to deal with this. Implement `PhabricatorApplicationTransactionInterface`, implicitly moving all the attach actions (task/task, task/revision, task/commit, task/mock) to proper edge transactions. The cost of this is that the inverse edges don't write transactions -- if you attach an object to another object, only the object you were acting on posts a transaction record. This is sort of buggy anyway already. I'll fix this in the next diff. Test Plan: Attached tasks, revisions and mocks to a task, then detached them. Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9838 --- src/__phutil_library_map__.php | 3 +- .../editor/ManiphestTransactionEditor.php | 8 +- .../event/ManiphestEdgeEventListener.php | 137 ------------------ .../maniphest/storage/ManiphestTask.php | 19 ++- .../PhabricatorSearchAttachController.php | 53 +++---- .../events/PhabricatorEventEngine.php | 1 - 6 files changed, 40 insertions(+), 181 deletions(-) delete mode 100644 src/applications/maniphest/event/ManiphestEdgeEventListener.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 39eb658120..2fbc1f25fd 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -926,7 +926,6 @@ phutil_register_library_map(array( 'ManiphestCustomFieldStorage' => 'applications/maniphest/storage/ManiphestCustomFieldStorage.php', 'ManiphestCustomFieldStringIndex' => 'applications/maniphest/storage/ManiphestCustomFieldStringIndex.php', 'ManiphestDAO' => 'applications/maniphest/storage/ManiphestDAO.php', - 'ManiphestEdgeEventListener' => 'applications/maniphest/event/ManiphestEdgeEventListener.php', 'ManiphestExcelDefaultFormat' => 'applications/maniphest/export/ManiphestExcelDefaultFormat.php', 'ManiphestExcelFormat' => 'applications/maniphest/export/ManiphestExcelFormat.php', 'ManiphestExportController' => 'applications/maniphest/controller/ManiphestExportController.php', @@ -3674,7 +3673,6 @@ phutil_register_library_map(array( 'ManiphestCustomFieldStorage' => 'PhabricatorCustomFieldStorage', 'ManiphestCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage', 'ManiphestDAO' => 'PhabricatorLiskDAO', - 'ManiphestEdgeEventListener' => 'PhabricatorEventListener', 'ManiphestExcelDefaultFormat' => 'ManiphestExcelFormat', 'ManiphestExportController' => 'ManiphestController', 'ManiphestHovercardEventListener' => 'PhabricatorEventListener', @@ -3697,6 +3695,7 @@ phutil_register_library_map(array( 5 => 'PhrequentTrackableInterface', 6 => 'PhabricatorCustomFieldInterface', 7 => 'PhabricatorDestructableInterface', + 8 => 'PhabricatorApplicationTransactionInterface', ), 'ManiphestTaskDescriptionPreviewController' => 'ManiphestController', 'ManiphestTaskDetailController' => 'ManiphestController', diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index a8c69cba24..3bca85686d 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -9,6 +9,7 @@ final class ManiphestTransactionEditor $types = parent::getTransactionTypes(); $types[] = PhabricatorTransactions::TYPE_COMMENT; + $types[] = PhabricatorTransactions::TYPE_EDGE; $types[] = ManiphestTransaction::TYPE_PRIORITY; $types[] = ManiphestTransaction::TYPE_STATUS; $types[] = ManiphestTransaction::TYPE_TITLE; @@ -16,7 +17,6 @@ final class ManiphestTransactionEditor $types[] = ManiphestTransaction::TYPE_OWNER; $types[] = ManiphestTransaction::TYPE_CCS; $types[] = ManiphestTransaction::TYPE_PROJECTS; - $types[] = ManiphestTransaction::TYPE_EDGE; $types[] = ManiphestTransaction::TYPE_SUBPRIORITY; $types[] = ManiphestTransaction::TYPE_PROJECT_COLUMN; $types[] = ManiphestTransaction::TYPE_UNBLOCK; @@ -57,7 +57,6 @@ final class ManiphestTransactionEditor return array_values(array_unique($object->getCCPHIDs())); case ManiphestTransaction::TYPE_PROJECTS: return array_values(array_unique($object->getProjectPHIDs())); - case ManiphestTransaction::TYPE_EDGE: case ManiphestTransaction::TYPE_PROJECT_COLUMN: // These are pre-populated. return $xaction->getOldValue(); @@ -82,7 +81,6 @@ final class ManiphestTransactionEditor case ManiphestTransaction::TYPE_STATUS: case ManiphestTransaction::TYPE_TITLE: case ManiphestTransaction::TYPE_DESCRIPTION: - case ManiphestTransaction::TYPE_EDGE: case ManiphestTransaction::TYPE_SUBPRIORITY: case ManiphestTransaction::TYPE_PROJECT_COLUMN: case ManiphestTransaction::TYPE_UNBLOCK: @@ -155,10 +153,6 @@ final class ManiphestTransactionEditor $object->setProjectPHIDs($xaction->getNewValue()); ManiphestTaskProject::updateTaskProjects($object); return $object; - case ManiphestTransaction::TYPE_EDGE: - // These are a weird, funky mess and are already being applied by the - // time we reach this. - return; case ManiphestTransaction::TYPE_SUBPRIORITY: $data = $xaction->getNewValue(); $new_sub = $this->getNextSubpriority( diff --git a/src/applications/maniphest/event/ManiphestEdgeEventListener.php b/src/applications/maniphest/event/ManiphestEdgeEventListener.php deleted file mode 100644 index 8e2552d110..0000000000 --- a/src/applications/maniphest/event/ManiphestEdgeEventListener.php +++ /dev/null @@ -1,137 +0,0 @@ -listen(PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES); - $this->listen(PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES); - } - - public function handleEvent(PhutilEvent $event) { - switch ($event->getType()) { - case PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES: - return $this->handleWillEditEvent($event); - case PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES: - return $this->handleDidEditEvent($event); - } - } - - private function handleWillEditEvent(PhutilEvent $event) { - // NOTE: Everything is namespaced by `id` so that we aren't left in an - // inconsistent state if an edit fails to complete (e.g., something throws) - // or an edit happens inside another edit. - - $id = $event->getValue('id'); - - $edges = $this->loadAllEdges($event); - $tasks = array(); - if ($edges) { - // TODO: T603 This should probably all get nuked. Until then, this isn't - // realllllly a policy issue since callers are (or should be) doing - // policy checks anyway. - $tasks = id(new ManiphestTask())->loadAllWhere( - 'phid IN (%Ls)', - array_keys($edges)); - $tasks = mpull($tasks, null, 'getPHID'); - } - - $this->edges[$id] = $edges; - $this->tasks[$id] = $tasks; - } - - private function handleDidEditEvent(PhutilEvent $event) { - $id = $event->getValue('id'); - - $old_edges = $this->edges[$id]; - $tasks = $this->tasks[$id]; - - unset($this->edges[$id]); - unset($this->tasks[$id]); - - $content_source = PhabricatorContentSource::newForSource( - PhabricatorContentSource::SOURCE_LEGACY, - array()); - - $new_edges = $this->loadAllEdges($event); - $editor = id(new ManiphestTransactionEditor()) - ->setActor($event->getUser()) - ->setContentSource($content_source) - ->setContinueOnNoEffect(true) - ->setContinueOnMissingFields(true); - - foreach ($tasks as $phid => $task) { - $xactions = array(); - - $old = $old_edges[$phid]; - $new = $new_edges[$phid]; - - $types = array_keys($old + $new); - foreach ($types as $type) { - $old_type = idx($old, $type, array()); - $new_type = idx($new, $type, array()); - - if ($old_type === $new_type) { - continue; - } - - $xactions[] = id(new ManiphestTransaction()) - ->setTransactionType(ManiphestTransaction::TYPE_EDGE) - ->setOldValue($old_type) - ->setNewValue($new_type) - ->setMetadataValue('edge:type', $type); - } - - if ($xactions) { - $editor->applyTransactions($task, $xactions); - } - } - } - - private function filterEdgesBySourceType(array $edges, $type) { - foreach ($edges as $key => $edge) { - if ($edge['src_type'] !== $type) { - unset($edges[$key]); - } - } - return $edges; - } - - private function loadAllEdges(PhutilEvent $event) { - $add_edges = $event->getValue('add'); - $rem_edges = $event->getValue('rem'); - - $type_task = ManiphestPHIDTypeTask::TYPECONST; - - $all_edges = array_merge($add_edges, $rem_edges); - $all_edges = $this->filterEdgesBySourceType($all_edges, $type_task); - - if (!$all_edges) { - return; - } - - $all_tasks = array(); - $all_types = array(); - foreach ($all_edges as $edge) { - $all_tasks[$edge['src']] = true; - $all_types[$edge['type']] = true; - } - - $all_tasks = array_keys($all_tasks); - $all_types = array_keys($all_types); - - return id(new PhabricatorEdgeQuery()) - ->withSourcePHIDs($all_tasks) - ->withEdgeTypes($all_types) - ->needEdgeData(true) - ->execute(); - } - -} diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index 2a88ba9864..9f9d9ca26e 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -8,7 +8,8 @@ final class ManiphestTask extends ManiphestDAO PhabricatorFlaggableInterface, PhrequentTrackableInterface, PhabricatorCustomFieldInterface, - PhabricatorDestructableInterface { + PhabricatorDestructableInterface, + PhabricatorApplicationTransactionInterface { const MARKUP_FIELD_DESCRIPTION = 'markup:desc'; @@ -303,4 +304,20 @@ final class ManiphestTask extends ManiphestDAO $this->saveTransaction(); } + +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new ManiphestTransactionEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new ManiphestTransaction(); + } + } diff --git a/src/applications/search/controller/PhabricatorSearchAttachController.php b/src/applications/search/controller/PhabricatorSearchAttachController.php index a799aa7b67..1459e404e1 100644 --- a/src/applications/search/controller/PhabricatorSearchAttachController.php +++ b/src/applications/search/controller/PhabricatorSearchAttachController.php @@ -57,45 +57,32 @@ final class PhabricatorSearchAttachController $phids = array_values($phids); if ($edge_type) { - $do_txn = $object instanceof PhabricatorApplicationTransactionInterface; + if (!$object instanceof PhabricatorApplicationTransactionInterface) { + throw new Exception( + pht( + 'Expected object ("%s") to implement interface "%s".', + get_class($object), + 'PhabricatorApplicationTransactionInterface')); + } + $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $this->phid, $edge_type); $add_phids = $phids; $rem_phids = array_diff($old_phids, $add_phids); - if ($do_txn) { - - $txn_editor = $object->getApplicationTransactionEditor() - ->setActor($user) - ->setContentSourceFromRequest($request); - $txn_template = $object->getApplicationTransactionTemplate() - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) - ->setMetadataValue('edge:type', $edge_type) - ->setNewValue(array( - '+' => array_fuse($add_phids), - '-' => array_fuse($rem_phids))); - $txn_editor->applyTransactions( - $object->getApplicationTransactionObject(), - array($txn_template)); - - } else { - - $editor = id(new PhabricatorEdgeEditor()); - $editor->setActor($user); - foreach ($add_phids as $phid) { - $editor->addEdge($this->phid, $edge_type, $phid); - } - foreach ($rem_phids as $phid) { - $editor->removeEdge($this->phid, $edge_type, $phid); - } - - try { - $editor->save(); - } catch (PhabricatorEdgeCycleException $ex) { - $this->raiseGraphCycleException($ex); - } - } + $txn_editor = $object->getApplicationTransactionEditor() + ->setActor($user) + ->setContentSourceFromRequest($request); + $txn_template = $object->getApplicationTransactionTemplate() + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $edge_type) + ->setNewValue(array( + '+' => array_fuse($add_phids), + '-' => array_fuse($rem_phids))); + $txn_editor->applyTransactions( + $object->getApplicationTransactionObject(), + array($txn_template)); return id(new AphrontReloadResponse())->setURI($handle->getURI()); } else { diff --git a/src/infrastructure/events/PhabricatorEventEngine.php b/src/infrastructure/events/PhabricatorEventEngine.php index 9959efe664..67807317c6 100644 --- a/src/infrastructure/events/PhabricatorEventEngine.php +++ b/src/infrastructure/events/PhabricatorEventEngine.php @@ -25,7 +25,6 @@ final class PhabricatorEventEngine { // Add builtin listeners. $listeners[] = new DarkConsoleEventPluginAPI(); - $listeners[] = new ManiphestEdgeEventListener(); // Add application listeners. $applications = PhabricatorApplication::getAllInstalledApplications(); From 533e799c5f7e18892af39a73bac33890b09fc4f7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:41:08 -0700 Subject: [PATCH 07/44] Modernize task/revision edges and write inverse transactions Summary: Ref T5245. See some discussion in D9838. When we attach object A to object B, we'd like to write transactions on both sides but only write the actual edges once. To do this, allow edge types to `shouldWriteInverseTransactions()`. When an edge type opts into this, have editors apply the inverse transactions before writing the edge. These inverse transactions don't actually apply effects, they just show up in the transaction log. Test Plan: Attached and detached revisions from tasks, saw transactions appear on both sides of the operation. Reviewers: chad, btrahan, joshuaspence Reviewed By: btrahan, joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9839 --- .../patches/migrate-maniphest-revisions.php | 2 +- src/__phutil_library_map__.php | 4 + .../DifferentialManiphestTasksField.php | 4 +- .../DifferentialRevisionHasTaskEdgeType.php | 105 ++++++++++++++++++ .../editor/DifferentialTransactionEditor.php | 4 +- .../DifferentialHovercardEventListener.php | 2 +- .../ManiphestTaskDetailController.php | 14 +-- .../edge/ManiphestTaskHasRevisionEdgeType.php | 105 ++++++++++++++++++ .../PhabricatorSearchAttachController.php | 4 +- ...habricatorApplicationTransactionEditor.php | 86 +++++++++++++- .../edges/constants/PhabricatorEdgeConfig.php | 18 +-- .../edges/editor/PhabricatorEdgeEditor.php | 8 +- .../edges/type/PhabricatorEdgeType.php | 4 + 13 files changed, 323 insertions(+), 37 deletions(-) create mode 100644 src/applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php create mode 100644 src/applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php diff --git a/resources/sql/patches/migrate-maniphest-revisions.php b/resources/sql/patches/migrate-maniphest-revisions.php index 788da47e92..3bcb05c855 100644 --- a/resources/sql/patches/migrate-maniphest-revisions.php +++ b/resources/sql/patches/migrate-maniphest-revisions.php @@ -19,7 +19,7 @@ foreach (new LiskMigrationIterator($table) as $task) { foreach ($revs as $rev) { $editor->addEdge( $task->getPHID(), - PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV, + ManiphestTaskHasRevisionEdgeType::EDGECONST, $rev); } $editor->save(); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 2fbc1f25fd..9b7b80ebeb 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -438,6 +438,7 @@ phutil_register_library_map(array( 'DifferentialRevisionControlSystem' => 'applications/differential/constants/DifferentialRevisionControlSystem.php', 'DifferentialRevisionDetailView' => 'applications/differential/view/DifferentialRevisionDetailView.php', 'DifferentialRevisionEditController' => 'applications/differential/controller/DifferentialRevisionEditController.php', + 'DifferentialRevisionHasTaskEdgeType' => 'applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php', 'DifferentialRevisionIDField' => 'applications/differential/customfield/DifferentialRevisionIDField.php', 'DifferentialRevisionLandController' => 'applications/differential/controller/DifferentialRevisionLandController.php', 'DifferentialRevisionListController' => 'applications/differential/controller/DifferentialRevisionListController.php', @@ -944,6 +945,7 @@ phutil_register_library_map(array( 'ManiphestTaskDescriptionPreviewController' => 'applications/maniphest/controller/ManiphestTaskDescriptionPreviewController.php', 'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php', 'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php', + 'ManiphestTaskHasRevisionEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php', 'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php', 'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php', 'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php', @@ -3153,6 +3155,7 @@ phutil_register_library_map(array( ), 'DifferentialRevisionDetailView' => 'AphrontView', 'DifferentialRevisionEditController' => 'DifferentialController', + 'DifferentialRevisionHasTaskEdgeType' => 'PhabricatorEdgeType', 'DifferentialRevisionIDField' => 'DifferentialCustomField', 'DifferentialRevisionLandController' => 'DifferentialController', 'DifferentialRevisionListController' => 'DifferentialController', @@ -3700,6 +3703,7 @@ phutil_register_library_map(array( 'ManiphestTaskDescriptionPreviewController' => 'ManiphestController', 'ManiphestTaskDetailController' => 'ManiphestController', 'ManiphestTaskEditController' => 'ManiphestController', + 'ManiphestTaskHasRevisionEdgeType' => 'PhabricatorEdgeType', 'ManiphestTaskListController' => 'ManiphestController', 'ManiphestTaskListView' => 'ManiphestView', 'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver', diff --git a/src/applications/differential/customfield/DifferentialManiphestTasksField.php b/src/applications/differential/customfield/DifferentialManiphestTasksField.php index 6e12b46a01..fbf05c708f 100644 --- a/src/applications/differential/customfield/DifferentialManiphestTasksField.php +++ b/src/applications/differential/customfield/DifferentialManiphestTasksField.php @@ -42,7 +42,7 @@ final class DifferentialManiphestTasksField return PhabricatorEdgeQuery::loadDestinationPHIDs( $revision->getPHID(), - PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK); + DifferentialRevisionHasTaskEdgeType::EDGECONST); } public function getApplicationTransactionType() { @@ -51,7 +51,7 @@ final class DifferentialManiphestTasksField public function getApplicationTransactionMetadata() { return array( - 'edge:type' => PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK, + 'edge:type' => DifferentialRevisionHasTaskEdgeType::EDGECONST, ); } diff --git a/src/applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php b/src/applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php new file mode 100644 index 0000000000..de9a9cad57 --- /dev/null +++ b/src/applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php @@ -0,0 +1,105 @@ +execute(); if ($tasks) { - $edge_related = PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK; + $edge_related = DifferentialRevisionHasTaskEdgeType::EDGECONST; $edges[$edge_related] = mpull($tasks, 'getPHID', 'getPHID'); } } diff --git a/src/applications/differential/event/DifferentialHovercardEventListener.php b/src/applications/differential/event/DifferentialHovercardEventListener.php index ae9fd0011b..06b5cfde96 100644 --- a/src/applications/differential/event/DifferentialHovercardEventListener.php +++ b/src/applications/differential/event/DifferentialHovercardEventListener.php @@ -28,7 +28,7 @@ final class DifferentialHovercardEventListener $rev->loadRelationships(); $reviewer_phids = $rev->getReviewers(); - $e_task = PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK; + $e_task = DifferentialRevisionHasTaskEdgeType::EDGECONST; $edge_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs(array($phid)) ->withEdgeTypes( diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index 8d24d59a49..b75c7c1ce1 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -54,7 +54,7 @@ final class ManiphestTaskDetailController extends ManiphestController { $e_commit = PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT; $e_dep_on = PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK; $e_dep_by = PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK; - $e_rev = PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV; + $e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST; $e_mock = PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK; $phid = $task->getPHID(); @@ -590,13 +590,13 @@ final class ManiphestTaskDetailController extends ManiphestController { $edge_types = array( PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK - => pht('Blocks'), + => pht('Blocks'), PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK - => pht('Blocked By'), - PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV - => pht('Differential Revisions'), + => pht('Blocked By'), + ManiphestTaskHasRevisionEdgeType::EDGECONST + => pht('Differential Revisions'), PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK - => pht('Pholio Mocks'), + => pht('Pholio Mocks'), ); $revisions_commits = array(); @@ -616,7 +616,7 @@ final class ManiphestTaskDetailController extends ManiphestController { $revision_phid = key($drev_edges[$phid][$commit_drev]); $revision_handle = idx($handles, $revision_phid); if ($revision_handle) { - $task_drev = PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV; + $task_drev = ManiphestTaskHasRevisionEdgeType::EDGECONST; unset($edges[$task_drev][$revision_phid]); $revisions_commits[$phid] = hsprintf( '%s / %s', diff --git a/src/applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php b/src/applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php new file mode 100644 index 0000000000..6bd1e6c94e --- /dev/null +++ b/src/applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php @@ -0,0 +1,105 @@ + array( $t_cmit => PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT, $t_task => PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, - $t_drev => PhabricatorEdgeConfig::TYPE_TASK_HAS_RELATED_DREV, + $t_drev => ManiphestTaskHasRevisionEdgeType::EDGECONST, $t_mock => PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK, ), $t_drev => array( $t_drev => PhabricatorEdgeConfig::TYPE_DREV_DEPENDS_ON_DREV, - $t_task => PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK, + $t_task => DifferentialRevisionHasTaskEdgeType::EDGECONST, ), $t_mock => array( $t_task => PhabricatorEdgeConfig::TYPE_MOCK_HAS_TASK, diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 28b803c659..9f99017c23 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -24,6 +24,7 @@ abstract class PhabricatorApplicationTransactionEditor private $isPreview; private $isHeraldEditor; + private $isInverseEdgeEditor; private $actingAsPHID; private $disableEmail; @@ -120,6 +121,15 @@ abstract class PhabricatorApplicationTransactionEditor return $this->isPreview; } + public function setIsInverseEdgeEditor($is_inverse_edge_editor) { + $this->isInverseEdgeEditor = $is_inverse_edge_editor; + return $this; + } + + public function getIsInverseEdgeEditor() { + return $this->isInverseEdgeEditor; + } + public function setIsHeraldEditor($is_herald_editor) { $this->isHeraldEditor = $is_herald_editor; return $this; @@ -377,10 +387,25 @@ abstract class PhabricatorApplicationTransactionEditor break; case PhabricatorTransactions::TYPE_EDGE: + if ($this->getIsInverseEdgeEditor()) { + // If we're writing an inverse edge transaction, don't actually + // do anything. The initiating editor on the other side of the + // transaction will take care of the edge writes. + break; + } + $old = $xaction->getOldValue(); $new = $xaction->getNewValue(); $src = $object->getPHID(); - $type = $xaction->getMetadataValue('edge:type'); + $const = $xaction->getMetadataValue('edge:type'); + + $type = PhabricatorEdgeType::getByConstant($const); + if ($type->shouldWriteInverseTransactions()) { + $this->applyInverseEdgeTransactions( + $object, + $xaction, + $type->getInverseEdgeConstant()); + } foreach ($new as $dst_phid => $edge) { $new[$dst_phid]['src'] = $src; @@ -395,7 +420,7 @@ abstract class PhabricatorApplicationTransactionEditor continue; } } - $editor->removeEdge($src, $type, $dst_phid); + $editor->removeEdge($src, $const, $dst_phid); } foreach ($new as $dst_phid => $edge) { @@ -409,7 +434,7 @@ abstract class PhabricatorApplicationTransactionEditor 'data' => $edge['data'], ); - $editor->addEdge($src, $type, $dst_phid, $data); + $editor->addEdge($src, $const, $dst_phid, $data); } $editor->save(); @@ -2335,4 +2360,59 @@ abstract class PhabricatorApplicationTransactionEditor $editor->save(); } + private function applyInverseEdgeTransactions( + PhabricatorLiskDAO $object, + PhabricatorApplicationTransaction $xaction, + $inverse_type) { + + $old = $xaction->getOldValue(); + $new = $xaction->getNewValue(); + + $add = array_keys(array_diff_key($new, $old)); + $rem = array_keys(array_diff_key($old, $new)); + + $add = array_fuse($add); + $rem = array_fuse($rem); + $all = $add + $rem; + + $nodes = id(new PhabricatorObjectQuery()) + ->setViewer($this->requireActor()) + ->withPHIDs($all) + ->execute(); + + foreach ($nodes as $node) { + if (!($node instanceof PhabricatorApplicationTransactionInterface)) { + continue; + } + + $editor = $node->getApplicationTransactionEditor(); + $template = $node->getApplicationTransactionTemplate(); + $target = $node->getApplicationTransactionObject(); + + if (isset($add[$node->getPHID()])) { + $edge_edit_type = '+'; + } else { + $edge_edit_type = '-'; + } + + $template + ->setTransactionType($xaction->getTransactionType()) + ->setMetadataValue('edge:type', $inverse_type) + ->setNewValue( + array( + $edge_edit_type => array($object->getPHID() => $object->getPHID()), + )); + + $editor + ->setContinueOnNoEffect(true) + ->setContinueOnMissingFields(true) + ->setParentMessageID($this->getParentMessageID()) + ->setIsInverseEdgeEditor(true) + ->setActor($this->requireActor()) + ->setContentSource($this->getContentSource()); + + $editor->applyTransactions($target, array($template)); + } + } + } diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index eb951356c4..bfff37a813 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -19,9 +19,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { const TYPE_BLOG_HAS_BLOGGER = 9; const TYPE_BLOGGER_HAS_BLOG = 10; - const TYPE_TASK_HAS_RELATED_DREV = 11; - const TYPE_DREV_HAS_RELATED_TASK = 12; - const TYPE_PROJ_MEMBER = 13; const TYPE_MEMBER_OF_PROJ = 14; @@ -137,7 +134,7 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { return $map; } - public static function getInverse($edge_type) { + private static function getInverse($edge_type) { static $map = array( self::TYPE_TASK_HAS_COMMIT => self::TYPE_COMMIT_HAS_TASK, self::TYPE_COMMIT_HAS_TASK => self::TYPE_TASK_HAS_COMMIT, @@ -153,9 +150,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { self::TYPE_BLOG_HAS_BLOGGER => self::TYPE_BLOGGER_HAS_BLOG, self::TYPE_BLOGGER_HAS_BLOG => self::TYPE_BLOG_HAS_BLOGGER, - self::TYPE_TASK_HAS_RELATED_DREV => self::TYPE_DREV_HAS_RELATED_TASK, - self::TYPE_DREV_HAS_RELATED_TASK => self::TYPE_TASK_HAS_RELATED_DREV, - self::TYPE_PROJ_MEMBER => self::TYPE_MEMBER_OF_PROJ, self::TYPE_MEMBER_OF_PROJ => self::TYPE_PROJ_MEMBER, @@ -226,7 +220,7 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { return idx($map, $edge_type); } - public static function shouldPreventCycles($edge_type) { + private static function shouldPreventCycles($edge_type) { static $map = array( self::TYPE_TEST_NO_CYCLE => true, self::TYPE_TASK_DEPENDS_ON_TASK => true, @@ -272,12 +266,10 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { case self::TYPE_COMMIT_HAS_TASK: case self::TYPE_TASK_DEPENDS_ON_TASK: case self::TYPE_TASK_DEPENDED_ON_BY_TASK: - case self::TYPE_DREV_HAS_RELATED_TASK: case self::TYPE_MOCK_HAS_TASK: return '%s edited task(s), added %d: %s; removed %d: %s.'; case self::TYPE_DREV_DEPENDS_ON_DREV: case self::TYPE_DREV_DEPENDED_ON_BY_DREV: - case self::TYPE_TASK_HAS_RELATED_DREV: case self::TYPE_COMMIT_HAS_DREV: case self::TYPE_REVIEWER_FOR_DREV: return '%s edited revision(s), added %d: %s; removed %d: %s.'; @@ -354,11 +346,9 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { case self::TYPE_TASK_DEPENDED_ON_BY_TASK: return '%s added %d blocked task(s): %s.'; case self::TYPE_COMMIT_HAS_TASK: - case self::TYPE_DREV_HAS_RELATED_TASK: case self::TYPE_MOCK_HAS_TASK: return '%s added %d task(s): %s.'; case self::TYPE_DREV_DEPENDED_ON_BY_DREV: - case self::TYPE_TASK_HAS_RELATED_DREV: case self::TYPE_COMMIT_HAS_DREV: case self::TYPE_REVIEWER_FOR_DREV: return '%s added %d revision(s): %s.'; @@ -432,12 +422,10 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { case self::TYPE_TASK_DEPENDED_ON_BY_TASK: return '%s removed %d blocked task(s): %s.'; case self::TYPE_COMMIT_HAS_TASK: - case self::TYPE_DREV_HAS_RELATED_TASK: case self::TYPE_MOCK_HAS_TASK: return '%s removed %d task(s): %s.'; case self::TYPE_DREV_DEPENDS_ON_DREV: case self::TYPE_DREV_DEPENDED_ON_BY_DREV: - case self::TYPE_TASK_HAS_RELATED_DREV: case self::TYPE_COMMIT_HAS_DREV: case self::TYPE_REVIEWER_FOR_DREV: return '%s removed %d revision(s): %s.'; @@ -507,12 +495,10 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { case self::TYPE_COMMIT_HAS_TASK: case self::TYPE_TASK_DEPENDS_ON_TASK: case self::TYPE_TASK_DEPENDED_ON_BY_TASK: - case self::TYPE_DREV_HAS_RELATED_TASK: case self::TYPE_MOCK_HAS_TASK: return '%s updated tasks of %s.'; case self::TYPE_DREV_DEPENDS_ON_DREV: case self::TYPE_DREV_DEPENDED_ON_BY_DREV: - case self::TYPE_TASK_HAS_RELATED_DREV: case self::TYPE_COMMIT_HAS_DREV: case self::TYPE_REVIEWER_FOR_DREV: return '%s updated revisions of %s.'; diff --git a/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php b/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php index 7de1b43f3d..c5df01728a 100644 --- a/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php +++ b/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php @@ -180,8 +180,9 @@ final class PhabricatorEdgeEditor extends PhabricatorEditor { 'data' => $data, ); - $inverse = PhabricatorEdgeConfig::getInverse($type); - if ($inverse) { + $type_obj = PhabricatorEdgeType::getByConstant($type); + $inverse = $type_obj->getInverseEdgeConstant(); + if ($inverse !== null) { // If `inverse_data` is set, overwrite the edge data. Normally, just // write the same data to the inverse edge. @@ -398,7 +399,8 @@ final class PhabricatorEdgeEditor extends PhabricatorEditor { $edge_types[$edge['type']] = true; } foreach ($edge_types as $type => $ignored) { - if (!PhabricatorEdgeConfig::shouldPreventCycles($type)) { + $type_obj = PhabricatorEdgeType::getByConstant($type); + if (!$type_obj->shouldPreventCycles()) { unset($edge_types[$type]); } } diff --git a/src/infrastructure/edges/type/PhabricatorEdgeType.php b/src/infrastructure/edges/type/PhabricatorEdgeType.php index f26bac0be2..6c2f28e584 100644 --- a/src/infrastructure/edges/type/PhabricatorEdgeType.php +++ b/src/infrastructure/edges/type/PhabricatorEdgeType.php @@ -42,6 +42,10 @@ abstract class PhabricatorEdgeType extends Phobject { return false; } + public function shouldWriteInverseTransactions() { + return false; + } + public function getTransactionAddString( $actor, $add_count, From 8cbfb49b4e9346f2961fb6037be48293a1fcaaa0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:41:42 -0700 Subject: [PATCH 08/44] Remove all edge events Summary: Ref T5245. These were a bad idea. We no longer need actors for edge edits either, so remove those. Generally, edges have fit into the policy model as pure/low-level infrastructure, and they do not have any policy or capability information in and of themselves. Test Plan: `grep` Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9840 --- .../patches/20130201.revisionunsubscribed.php | 1 - resources/sql/patches/20130409.commitdrev.php | 4 +- .../sql/patches/20131004.dxreviewers.php | 4 +- .../20131121.repocredentials.2.mig.php | 1 - .../migrate-differential-dependencies.php | 1 - .../migrate-maniphest-dependencies.php | 1 - .../patches/migrate-maniphest-revisions.php | 1 - .../sql/patches/migrate-project-edges.php | 1 - src/__phutil_library_map__.php | 2 +- .../conpherence/editor/ConpherenceEditor.php | 3 +- .../DifferentialJIRAIssuesField.php | 3 +- .../DiffusionCommitEditController.php | 4 +- .../worker/DoorkeeperFeedWorkerAsana.php | 4 +- .../files/storage/PhabricatorFile.php | 2 - .../editor/LegalpadDocumentEditor.php | 1 - .../ManiphestTaskEditController.php | 1 - .../editor/ManiphestTransactionEditor.php | 5 +-- .../ponder/editor/PonderVoteEditor.php | 1 - .../PhabricatorProjectTransactionEditor.php | 3 +- .../editor/PhabricatorRepositoryEditor.php | 3 +- ...torRepositoryCommitMessageParserWorker.php | 2 - .../editor/PhabricatorSubscriptionsEditor.php | 3 +- .../engine/PhabricatorDestructionEngine.php | 3 +- ...habricatorApplicationTransactionEditor.php | 8 +--- src/docs/user/userguide/events.diviner | 34 --------------- .../__tests__/PhabricatorEdgeTestCase.php | 3 -- .../edges/editor/PhabricatorEdgeEditor.php | 42 ++----------------- .../events/constant/PhabricatorEventType.php | 3 -- 28 files changed, 19 insertions(+), 125 deletions(-) diff --git a/resources/sql/patches/20130201.revisionunsubscribed.php b/resources/sql/patches/20130201.revisionunsubscribed.php index 38f1e5207e..891be91bc1 100644 --- a/resources/sql/patches/20130201.revisionunsubscribed.php +++ b/resources/sql/patches/20130201.revisionunsubscribed.php @@ -19,7 +19,6 @@ foreach ($revs as $rev) { } $editor = new PhabricatorEdgeEditor(); - $editor->setSuppressEvents(true); foreach ($unsubscribed as $user_phid => $_) { $editor->addEdge( $rev['phid'], diff --git a/resources/sql/patches/20130409.commitdrev.php b/resources/sql/patches/20130409.commitdrev.php index 86d00ac219..1fa7e6f871 100644 --- a/resources/sql/patches/20130409.commitdrev.php +++ b/resources/sql/patches/20130409.commitdrev.php @@ -3,7 +3,7 @@ echo "Migrating differential.revisionPHID to edges...\n"; $commit_table = new PhabricatorRepositoryCommit(); $data_table = new PhabricatorRepositoryCommitData(); -$editor = id(new PhabricatorEdgeEditor())->setSuppressEvents(true); +$editor = new PhabricatorEdgeEditor(); $commit_table->establishConnection('w'); $edges = 0; @@ -24,7 +24,7 @@ foreach (new LiskMigrationIterator($commit_table) as $commit) { if ($edges % 256 == 0) { echo '.'; $editor->save(); - $editor = id(new PhabricatorEdgeEditor())->setSuppressEvents(true); + $editor = new PhabricatorEdgeEditor(); } } diff --git a/resources/sql/patches/20131004.dxreviewers.php b/resources/sql/patches/20131004.dxreviewers.php index 8ff3bc32f8..ab683e2a3f 100644 --- a/resources/sql/patches/20131004.dxreviewers.php +++ b/resources/sql/patches/20131004.dxreviewers.php @@ -25,9 +25,7 @@ foreach (new LiskMigrationIterator($table) as $revision) { continue; } - $editor = id(new PhabricatorEdgeEditor()) - ->setActor(PhabricatorUser::getOmnipotentUser()); - + $editor = new PhabricatorEdgeEditor(); foreach ($reviewer_phids as $dst) { if (phid_get_type($dst) == PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) { // At least one old install ran into some issues here. Skip the row if we diff --git a/resources/sql/patches/20131121.repocredentials.2.mig.php b/resources/sql/patches/20131121.repocredentials.2.mig.php index 6148ca87df..95fd9a43fa 100644 --- a/resources/sql/patches/20131121.repocredentials.2.mig.php +++ b/resources/sql/patches/20131121.repocredentials.2.mig.php @@ -121,7 +121,6 @@ foreach ($map as $credential_type => $credential_usernames) { $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_USES_CREDENTIAL; id(new PhabricatorEdgeEditor()) - ->setActor($viewer) ->addEdge($repository->getPHID(), $edge_type, $credential->getPHID()) ->save(); } diff --git a/resources/sql/patches/migrate-differential-dependencies.php b/resources/sql/patches/migrate-differential-dependencies.php index 15301de979..ea2f9c6916 100644 --- a/resources/sql/patches/migrate-differential-dependencies.php +++ b/resources/sql/patches/migrate-differential-dependencies.php @@ -15,7 +15,6 @@ foreach (new LiskMigrationIterator($table) as $rev) { } $editor = new PhabricatorEdgeEditor(); - $editor->setSuppressEvents(true); foreach ($deps as $dep) { $editor->addEdge( $rev->getPHID(), diff --git a/resources/sql/patches/migrate-maniphest-dependencies.php b/resources/sql/patches/migrate-maniphest-dependencies.php index 51f1c944e9..b72d52be8a 100644 --- a/resources/sql/patches/migrate-maniphest-dependencies.php +++ b/resources/sql/patches/migrate-maniphest-dependencies.php @@ -15,7 +15,6 @@ foreach (new LiskMigrationIterator($table) as $task) { } $editor = new PhabricatorEdgeEditor(); - $editor->setSuppressEvents(true); foreach ($deps as $dep) { $editor->addEdge( $task->getPHID(), diff --git a/resources/sql/patches/migrate-maniphest-revisions.php b/resources/sql/patches/migrate-maniphest-revisions.php index 3bcb05c855..eeb9a7f4e2 100644 --- a/resources/sql/patches/migrate-maniphest-revisions.php +++ b/resources/sql/patches/migrate-maniphest-revisions.php @@ -15,7 +15,6 @@ foreach (new LiskMigrationIterator($table) as $task) { } $editor = new PhabricatorEdgeEditor(); - $editor->setSuppressEvents(true); foreach ($revs as $rev) { $editor->addEdge( $task->getPHID(), diff --git a/resources/sql/patches/migrate-project-edges.php b/resources/sql/patches/migrate-project-edges.php index f64fa40efd..844e4434ba 100644 --- a/resources/sql/patches/migrate-project-edges.php +++ b/resources/sql/patches/migrate-project-edges.php @@ -22,7 +22,6 @@ foreach (new LiskMigrationIterator($table) as $proj) { $members = ipull($members, 'userPHID'); $editor = new PhabricatorEdgeEditor(); - $editor->setSuppressEvents(true); foreach ($members as $user_phid) { $editor->addEdge( $proj->getPHID(), diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 9b7b80ebeb..f4171d374f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4357,7 +4357,7 @@ phutil_register_library_map(array( 'PhabricatorDraftDAO' => 'PhabricatorLiskDAO', 'PhabricatorEdgeConfig' => 'PhabricatorEdgeConstants', 'PhabricatorEdgeCycleException' => 'Exception', - 'PhabricatorEdgeEditor' => 'PhabricatorEditor', + 'PhabricatorEdgeEditor' => 'Phobject', 'PhabricatorEdgeGraph' => 'AbstractDirectedGraph', 'PhabricatorEdgeQuery' => 'PhabricatorQuery', 'PhabricatorEdgeTestCase' => 'PhabricatorTestCase', diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php index 8389995b5c..5a16008818 100644 --- a/src/applications/conpherence/editor/ConpherenceEditor.php +++ b/src/applications/conpherence/editor/ConpherenceEditor.php @@ -216,8 +216,7 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { switch ($xaction->getTransactionType()) { case ConpherenceTransactionType::TYPE_FILES: - $editor = id(new PhabricatorEdgeEditor()) - ->setActor($this->getActor()); + $editor = new PhabricatorEdgeEditor(); $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; $old = array_fill_keys($xaction->getOldValue(), true); $new = array_fill_keys($xaction->getNewValue(), true); diff --git a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php index 12c7ea9ebb..3d0c6d61ac 100644 --- a/src/applications/differential/customfield/DifferentialJIRAIssuesField.php +++ b/src/applications/differential/customfield/DifferentialJIRAIssuesField.php @@ -257,8 +257,7 @@ final class DifferentialJIRAIssuesField $revision_phid, $edge_type); - $editor = id(new PhabricatorEdgeEditor()) - ->setActor($this->getViewer()); + $editor = new PhabricatorEdgeEditor(); foreach (array_diff($edges, $edge_dsts) as $rem_edge) { $editor->removeEdge($revision_phid, $edge_type, $rem_edge); diff --git a/src/applications/diffusion/controller/DiffusionCommitEditController.php b/src/applications/diffusion/controller/DiffusionCommitEditController.php index 35445cabe3..8ce41bb600 100644 --- a/src/applications/diffusion/controller/DiffusionCommitEditController.php +++ b/src/applications/diffusion/controller/DiffusionCommitEditController.php @@ -34,8 +34,8 @@ final class DiffusionCommitEditController extends DiffusionController { $new_proj_phids = array_values($proj_phids); $rem_proj_phids = array_diff($current_proj_phids, $new_proj_phids); - $editor = id(new PhabricatorEdgeEditor()); - $editor->setActor($user); + + $editor = id(new PhabricatorEdgeEditor()); foreach ($rem_proj_phids as $phid) { $editor->removeEdge($commit_phid, $edge_type, $phid); } diff --git a/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php b/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php index 4cb18ea80d..804fe18a48 100644 --- a/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php +++ b/src/applications/doorkeeper/worker/DoorkeeperFeedWorkerAsana.php @@ -235,7 +235,6 @@ final class DoorkeeperFeedWorkerAsana extends DoorkeeperFeedWorker { ); id(new PhabricatorEdgeEditor()) - ->setActor($viewer) ->addEdge($src_phid, $etype_main, $dst_phid, $edge_options) ->save(); @@ -247,8 +246,7 @@ final class DoorkeeperFeedWorkerAsana extends DoorkeeperFeedWorker { // Now, handle the subtasks. - $sub_editor = id(new PhabricatorEdgeEditor()) - ->setActor($viewer); + $sub_editor = new PhabricatorEdgeEditor(); // First, find all the object references in Phabricator for tasks that we // know about and import their objects from Asana. diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php index 8ae6424a66..ec33019ec3 100644 --- a/src/applications/files/storage/PhabricatorFile.php +++ b/src/applications/files/storage/PhabricatorFile.php @@ -859,8 +859,6 @@ final class PhabricatorFile extends PhabricatorFileDAO $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; id(new PhabricatorEdgeEditor()) - ->setActor($actor) - ->setSuppressEvents(true) ->addEdge($phid, $edge_type, $this->getPHID()) ->save(); diff --git a/src/applications/legalpad/editor/LegalpadDocumentEditor.php b/src/applications/legalpad/editor/LegalpadDocumentEditor.php index c8904b0d42..8ab21daf9d 100644 --- a/src/applications/legalpad/editor/LegalpadDocumentEditor.php +++ b/src/applications/legalpad/editor/LegalpadDocumentEditor.php @@ -105,7 +105,6 @@ final class LegalpadDocumentEditor $type = PhabricatorEdgeConfig::TYPE_CONTRIBUTED_TO_OBJECT; id(new PhabricatorEdgeEditor()) ->addEdge($actor->getPHID(), $type, $object->getPHID()) - ->setActor($actor) ->save(); $type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_CONTRIBUTOR; diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index 438151d81c..a4c13242b0 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -330,7 +330,6 @@ final class ManiphestTaskEditController extends ManiphestController { if ($parent_task) { id(new PhabricatorEdgeEditor()) - ->setActor($user) ->addEdge( $parent_task->getPHID(), PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index 3bca85686d..5ed423bc74 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -225,10 +225,7 @@ final class ManiphestTransactionEditor return; } - $editor = id(new PhabricatorEdgeEditor()) - ->setActor($this->getActor()) - ->setSuppressEvents(true); - + $editor = new PhabricatorEdgeEditor(); foreach ($add as $phid) { $editor->addEdge($src, $edge_type, $phid); } diff --git a/src/applications/ponder/editor/PonderVoteEditor.php b/src/applications/ponder/editor/PonderVoteEditor.php index c1448d2b7a..cc9f89d9fe 100644 --- a/src/applications/ponder/editor/PonderVoteEditor.php +++ b/src/applications/ponder/editor/PonderVoteEditor.php @@ -34,7 +34,6 @@ final class PonderVoteEditor extends PhabricatorEditor { // prepare vote add, or update if this user is amending an // earlier vote $editor = id(new PhabricatorEdgeEditor()) - ->setActor($actor) ->addEdge( $actor->getPHID(), $votable->getUserVoteEdgeType(), diff --git a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php index 73cbcbd168..386fb150d5 100644 --- a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php +++ b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php @@ -231,8 +231,7 @@ final class PhabricatorProjectTransactionEditor if ($rem) { // When removing members, also remove any watches on the project. - $edge_editor = id(new PhabricatorEdgeEditor()) - ->setSuppressEvents(true); + $edge_editor = new PhabricatorEdgeEditor(); foreach ($rem as $rem_phid) { $edge_editor->removeEdge( $object->getPHID(), diff --git a/src/applications/repository/editor/PhabricatorRepositoryEditor.php b/src/applications/repository/editor/PhabricatorRepositoryEditor.php index 700a271c84..841a65d9d1 100644 --- a/src/applications/repository/editor/PhabricatorRepositoryEditor.php +++ b/src/applications/repository/editor/PhabricatorRepositoryEditor.php @@ -225,8 +225,7 @@ final class PhabricatorRepositoryEditor $old_phid = $xaction->getOldValue(); $new_phid = $xaction->getNewValue(); - $editor = id(new PhabricatorEdgeEditor()) - ->setActor($this->requireActor()); + $editor = new PhabricatorEdgeEditor(); $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_USES_CREDENTIAL; $src_phid = $object->getPHID(); diff --git a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php index 0296c6124c..10c5ba097e 100644 --- a/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php @@ -90,7 +90,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker if ($revision) { $commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV; id(new PhabricatorEdgeEditor()) - ->setActor($user) ->addEdge($commit->getPHID(), $commit_drev, $revision->getPHID()) ->save(); @@ -453,7 +452,6 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker // Maniphest edges is sorted out. Currently, Maniphest reacts to an edge // edit on this edge. id(new PhabricatorEdgeEditor()) - ->setActor($actor) ->addEdge( $task->getPHID(), PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT, diff --git a/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php b/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php index ab73feda8b..9b58b61797 100644 --- a/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php +++ b/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php @@ -83,8 +83,7 @@ final class PhabricatorSubscriptionsEditor extends PhabricatorEditor { $u_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER; $s_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER; - $editor = id(new PhabricatorEdgeEditor()) - ->setActor($actor); + $editor = new PhabricatorEdgeEditor(); foreach ($add as $phid => $ignored) { $editor->removeEdge($src, $u_type, $phid); diff --git a/src/applications/system/engine/PhabricatorDestructionEngine.php b/src/applications/system/engine/PhabricatorDestructionEngine.php index 7b40c26726..eedda85151 100644 --- a/src/applications/system/engine/PhabricatorDestructionEngine.php +++ b/src/applications/system/engine/PhabricatorDestructionEngine.php @@ -62,8 +62,7 @@ final class PhabricatorDestructionEngine extends Phobject { return; } - $editor = id(new PhabricatorEdgeEditor()) - ->setSuppressEvents(true); + $editor = new PhabricatorEdgeEditor(); foreach ($edges as $type => $type_edges) { foreach ($type_edges as $src => $src_edges) { foreach ($src_edges as $dst => $edge) { diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 9f99017c23..863814f66b 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -411,8 +411,7 @@ abstract class PhabricatorApplicationTransactionEditor $new[$dst_phid]['src'] = $src; } - $editor = id(new PhabricatorEdgeEditor()) - ->setActor($this->getActor()); + $editor = new PhabricatorEdgeEditor(); foreach ($old as $dst_phid => $edge) { if (!empty($new[$dst_phid])) { @@ -2346,11 +2345,6 @@ abstract class PhabricatorApplicationTransactionEditor $editor = id(new PhabricatorEdgeEditor()) ->setActor($this->getActor()); - // TODO: Edge-based events were almost certainly a terrible idea. If we - // don't suppress this event, the Maniphest listener reenters and adds - // more transactions. Just suppress it until that can get cleaned up. - $editor->setSuppressEvents(true); - $src = $object->getPHID(); $type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; foreach ($file_phids as $dst) { diff --git a/src/docs/user/userguide/events.diviner b/src/docs/user/userguide/events.diviner index 292be9ec45..0ec3542f3f 100644 --- a/src/docs/user/userguide/events.diviner +++ b/src/docs/user/userguide/events.diviner @@ -236,40 +236,6 @@ Data available on this event: Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query. -== Edge: Will Edit Edges == - -NOTE: Edge events are low-level events deep in the core. It is more difficult to -correct implement listeners for these events than for higher-level events. - -The constant for this event is -`PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES`. - -This event is dispatched before @{class:PhabricatorEdgeEditor} makes an edge -edit. - - - `id` An identifier for this edit operation. - - `add` A list of dictionaries, each representing a new edge. - - `rem` A list of dictionaries, each representing a removed edge. - -This is similar to the next event (did edit edges) but occurs before the -edit begins. - -== Edge: Did Edit Edges == - -The constant for this event is -`PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES`. - -This event is dispatched after @{class:PhabricatorEdgeEditor} makes an edge -edit, but before it commits the transactions. Data available on this event: - - - `id` An identifier for this edit operation. This is the same ID as - the one included in the corresponding "will edit edges" event. - - `add` A list of dictionaries, each representing a new edge. - - `rem` A list of dictionaries, each representing a removed edge. - -This is similar to the previous event (will edit edges) but occurs after the -edit completes. - == Search: Did Update Index == The constant for this event is diff --git a/src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php b/src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php index d15ed23c61..48dffdc9f5 100644 --- a/src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php +++ b/src/infrastructure/edges/__tests__/PhabricatorEdgeTestCase.php @@ -21,7 +21,6 @@ final class PhabricatorEdgeTestCase extends PhabricatorTestCase { $phid2 = $obj2->getPHID(); $editor = id(new PhabricatorEdgeEditor()) - ->setActor($user) ->addEdge($phid1, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid2) ->addEdge($phid2, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid1); @@ -39,12 +38,10 @@ final class PhabricatorEdgeTestCase extends PhabricatorTestCase { // fail (it introduces a cycle). $editor = id(new PhabricatorEdgeEditor()) - ->setActor($user) ->addEdge($phid1, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid2) ->save(); $editor = id(new PhabricatorEdgeEditor()) - ->setActor($user) ->addEdge($phid2, PhabricatorEdgeConfig::TYPE_TEST_NO_CYCLE, $phid1); $caught = null; diff --git a/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php b/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php index c5df01728a..42909ee6e2 100644 --- a/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php +++ b/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php @@ -5,6 +5,9 @@ * @{class:PhabricatorEdgeQuery} to load object edges. For more information * on edges, see @{article:Using Edges}. * + * Edges are not directly policy aware, and this editor makes low-level changes + * below the policy layer. + * * name=Adding Edges * $src = $earth_phid; * $type = PhabricatorEdgeConfig::TYPE_BODY_HAS_SATELLITE; @@ -12,19 +15,17 @@ * * id(new PhabricatorEdgeEditor()) * ->addEdge($src, $type, $dst) - * ->setActor($user) * ->save(); * * @task edit Editing Edges * @task cycles Cycle Prevention * @task internal Internals */ -final class PhabricatorEdgeEditor extends PhabricatorEditor { +final class PhabricatorEdgeEditor extends Phobject { private $addEdges = array(); private $remEdges = array(); private $openTransactions = array(); - private $suppressEvents; /* -( Editing Edges )------------------------------------------------------ */ @@ -118,8 +119,6 @@ final class PhabricatorEdgeEditor extends PhabricatorEditor { static $id = 0; $id++; - $this->sendEvent($id, PhabricatorEventType::TYPE_EDGE_WILLEDITEDGES); - // NOTE: Removes first, then adds, so that "remove + add" is a useful // operation meaning "overwrite". @@ -130,8 +129,6 @@ final class PhabricatorEdgeEditor extends PhabricatorEditor { $this->detectCycles($src_phids, $cycle_type); } - $this->sendEvent($id, PhabricatorEventType::TYPE_EDGE_DIDEDITEDGES); - $this->saveTransactions(); } catch (Exception $ex) { $caught = $ex; @@ -351,37 +348,6 @@ final class PhabricatorEdgeEditor extends PhabricatorEditor { } } - /** - * Suppress edge edit events. This prevents listeners from making updates in - * response to edits, and is primarily useful when performing migrations. You - * should not normally need to use it. - * - * @param bool True to suppress events related to edits. - * @return this - * @task internal - */ - public function setSuppressEvents($suppress) { - $this->suppressEvents = $suppress; - return $this; - } - - - private function sendEvent($edit_id, $event_type) { - if ($this->suppressEvents) { - return; - } - - $event = new PhabricatorEvent( - $event_type, - array( - 'id' => $edit_id, - 'add' => $this->addEdges, - 'rem' => $this->remEdges, - )); - $event->setUser($this->getActor()); - PhutilEventEngine::dispatchEvent($event); - } - /* -( Cycle Prevention )--------------------------------------------------- */ diff --git a/src/infrastructure/events/constant/PhabricatorEventType.php b/src/infrastructure/events/constant/PhabricatorEventType.php index f33cd4a2d4..a7de9465e2 100644 --- a/src/infrastructure/events/constant/PhabricatorEventType.php +++ b/src/infrastructure/events/constant/PhabricatorEventType.php @@ -16,9 +16,6 @@ final class PhabricatorEventType extends PhutilEventType { const TYPE_DIFFUSION_DIDDISCOVERCOMMIT = 'diffusion.didDiscoverCommit'; const TYPE_DIFFUSION_LOOKUPUSER = 'diffusion.lookupUser'; - const TYPE_EDGE_WILLEDITEDGES = 'edge.willEditEdges'; - const TYPE_EDGE_DIDEDITEDGES = 'edge.didEditEdges'; - const TYPE_TEST_DIDRUNTEST = 'test.didRunTest'; const TYPE_UI_DIDRENDERACTIONS = 'ui.didRenderActions'; From b32313cc85d8ba9932dd216a325daedfebfa56c1 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:41:54 -0700 Subject: [PATCH 09/44] Use PhabricatorEdgeType strings when rendering transactions Summary: Ref T5245. This hooks up the translation/rendering methods added previously. These are messy, but now extractable/translatable. Test Plan: Viewed edge transactions and stories, saw correct strings. Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9841 --- .../PhabricatorApplicationTransaction.php | 63 +++++++++++++------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php index 630dbb60ee..b1a0267fcd 100644 --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -591,28 +591,25 @@ abstract class PhabricatorApplicationTransaction $type = $this->getMetadata('edge:type'); $type = head($type); + $type_obj = PhabricatorEdgeType::getByConstant($type); + if ($add && $rem) { - $string = PhabricatorEdgeConfig::getEditStringForEdgeType($type); - return pht( - $string, + return $type_obj->getTransactionEditString( $this->renderHandleLink($author_phid), - count($add), + new PhutilNumber(count($add) + count($rem)), + new PhutilNumber(count($add)), $this->renderHandleList($add), - count($rem), + new PhutilNumber(count($rem)), $this->renderHandleList($rem)); } else if ($add) { - $string = PhabricatorEdgeConfig::getAddStringForEdgeType($type); - return pht( - $string, + return $type_obj->getTransactionAddString( $this->renderHandleLink($author_phid), - count($add), + new PhutilNumber(count($add)), $this->renderHandleList($add)); } else if ($rem) { - $string = PhabricatorEdgeConfig::getRemoveStringForEdgeType($type); - return pht( - $string, + return $type_obj->getTransactionRemoveString( $this->renderHandleLink($author_phid), - count($rem), + new PhutilNumber(count($rem)), $this->renderHandleList($rem)); } else { return pht( @@ -711,13 +708,43 @@ abstract class PhabricatorApplicationTransaction $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); case PhabricatorTransactions::TYPE_EDGE: + $new = ipull($new, 'dst'); + $old = ipull($old, 'dst'); + $add = array_diff($new, $old); + $rem = array_diff($old, $new); $type = $this->getMetadata('edge:type'); $type = head($type); - $string = PhabricatorEdgeConfig::getFeedStringForEdgeType($type); - return pht( - $string, - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid)); + + $type_obj = PhabricatorEdgeType::getByConstant($type); + + if ($add && $rem) { + return $type_obj->getFeedEditString( + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid), + new PhutilNumber(count($add) + count($rem)), + new PhutilNumber(count($add)), + $this->renderHandleList($add), + new PhutilNumber(count($rem)), + $this->renderHandleList($rem)); + } else if ($add) { + return $type_obj->getFeedAddString( + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid), + new PhutilNumber(count($add)), + $this->renderHandleList($add)); + } else if ($rem) { + return $type_obj->getFeedRemoveString( + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid), + new PhutilNumber(count($rem)), + $this->renderHandleList($rem)); + } else { + return pht( + '%s edited edge metadata for %s.', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid)); + } + case PhabricatorTransactions::TYPE_CUSTOMFIELD: $field = $this->getTransactionCustomField(); if ($field) { From d4b2bfa2f4c1354661c607af71cb794ed03632e5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:42:06 -0700 Subject: [PATCH 10/44] Modernize commit/edge transaction when parsing commit messages Summary: Ref T5245. With work elsewhere (notably, D9839) we can remove this TODO and use real transactions. Test Plan: Pushed a `closes Txxx` commit and got a close + transaction. Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9848 --- src/__phutil_library_map__.php | 4 + ...ConduitAPI_diffusion_getcommits_Method.php | 2 +- .../controller/DiffusionCommitController.php | 4 +- .../edge/DiffusionCommitHasTaskEdgeType.php | 103 ++++++++++++++++++ .../ManiphestTaskDetailController.php | 4 +- .../edge/ManiphestTaskHasCommitEdgeType.php | 103 ++++++++++++++++++ ...torRepositoryCommitMessageParserWorker.php | 16 +-- .../PhabricatorSearchAttachController.php | 4 +- .../edges/constants/PhabricatorEdgeConfig.php | 14 --- 9 files changed, 219 insertions(+), 35 deletions(-) create mode 100644 src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php create mode 100644 src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f4171d374f..e0ccee3f2d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -486,6 +486,7 @@ phutil_register_library_map(array( 'DiffusionCommitChangeTableView' => 'applications/diffusion/view/DiffusionCommitChangeTableView.php', 'DiffusionCommitController' => 'applications/diffusion/controller/DiffusionCommitController.php', 'DiffusionCommitEditController' => 'applications/diffusion/controller/DiffusionCommitEditController.php', + 'DiffusionCommitHasTaskEdgeType' => 'applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php', 'DiffusionCommitHash' => 'applications/diffusion/data/DiffusionCommitHash.php', 'DiffusionCommitHookEngine' => 'applications/diffusion/engine/DiffusionCommitHookEngine.php', 'DiffusionCommitHookRejectException' => 'applications/diffusion/exception/DiffusionCommitHookRejectException.php', @@ -945,6 +946,7 @@ phutil_register_library_map(array( 'ManiphestTaskDescriptionPreviewController' => 'applications/maniphest/controller/ManiphestTaskDescriptionPreviewController.php', 'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php', 'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php', + 'ManiphestTaskHasCommitEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php', 'ManiphestTaskHasRevisionEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php', 'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php', 'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php', @@ -3199,6 +3201,7 @@ phutil_register_library_map(array( 'DiffusionCommitChangeTableView' => 'DiffusionView', 'DiffusionCommitController' => 'DiffusionController', 'DiffusionCommitEditController' => 'DiffusionController', + 'DiffusionCommitHasTaskEdgeType' => 'PhabricatorEdgeType', 'DiffusionCommitHash' => 'Phobject', 'DiffusionCommitHookEngine' => 'Phobject', 'DiffusionCommitHookRejectException' => 'Exception', @@ -3703,6 +3706,7 @@ phutil_register_library_map(array( 'ManiphestTaskDescriptionPreviewController' => 'ManiphestController', 'ManiphestTaskDetailController' => 'ManiphestController', 'ManiphestTaskEditController' => 'ManiphestController', + 'ManiphestTaskHasCommitEdgeType' => 'PhabricatorEdgeType', 'ManiphestTaskHasRevisionEdgeType' => 'PhabricatorEdgeType', 'ManiphestTaskListController' => 'ManiphestController', 'ManiphestTaskListView' => 'ManiphestView', diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php index 46139ba66b..05a6a33dcf 100644 --- a/src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php +++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_getcommits_Method.php @@ -269,7 +269,7 @@ final class ConduitAPI_diffusion_getcommits_Method * Enhances the commits list with Maniphest information. */ private function addManiphestInformation(array $commits) { - $task_type = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK; + $task_type = DiffusionCommitHasTaskEdgeType::EDGECONST; $commit_phids = ipull($commits, 'commitPHID'); diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index c7dfdfd652..6716f0e033 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -420,7 +420,7 @@ final class DiffusionCommitController extends DiffusionController { $edge_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs(array($commit_phid)) ->withEdgeTypes(array( - PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK, + DiffusionCommitHasTaskEdgeType::EDGECONST, PhabricatorEdgeConfig::TYPE_COMMIT_HAS_PROJECT, PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV, )); @@ -428,7 +428,7 @@ final class DiffusionCommitController extends DiffusionController { $edges = $edge_query->execute(); $task_phids = array_keys( - $edges[$commit_phid][PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK]); + $edges[$commit_phid][DiffusionCommitHasTaskEdgeType::EDGECONST]); $proj_phids = array_keys( $edges[$commit_phid][PhabricatorEdgeConfig::TYPE_COMMIT_HAS_PROJECT]); $revision_phid = key( diff --git a/src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php b/src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php new file mode 100644 index 0000000000..516fcdf023 --- /dev/null +++ b/src/applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php @@ -0,0 +1,103 @@ +setViewer($user) ->readFieldsFromStorage($task); - $e_commit = PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT; + $e_commit = ManiphestTaskHasCommitEdgeType::EDGECONST; $e_dep_on = PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK; $e_dep_by = PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK; $e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST; @@ -603,7 +603,7 @@ final class ManiphestTaskDetailController extends ManiphestController { $handles = $this->getLoadedHandles(); $commit_phids = array_keys( - $edges[PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT]); + $edges[ManiphestTaskHasCommitEdgeType::EDGECONST]); if ($commit_phids) { $commit_drev = PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV; $drev_edges = id(new PhabricatorEdgeQuery()) diff --git a/src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php b/src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php new file mode 100644 index 0000000000..a9842f8ff1 --- /dev/null +++ b/src/applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php @@ -0,0 +1,103 @@ + $task) { $xactions = array(); - // TODO: Swap this for a real edge transaction once the weirdness in - // Maniphest edges is sorted out. Currently, Maniphest reacts to an edge - // edit on this edge. - id(new PhabricatorEdgeEditor()) - ->addEdge( - $task->getPHID(), - PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT, - $commit->getPHID()) - ->save(); - - /* TODO: Do this instead of the above. - + $edge_type = ManiphestTaskHasCommitEdgeType::EDGECONST; $xactions[] = id(new ManiphestTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) - ->setMetadataValue('edge:type', $edge_task_has_commit) + ->setMetadataValue('edge:type', $edge_type) ->setNewValue( array( '+' => array( $commit->getPHID() => $commit->getPHID(), ), )); - */ $status = $task_statuses[$task_id]; if ($status) { diff --git a/src/applications/search/controller/PhabricatorSearchAttachController.php b/src/applications/search/controller/PhabricatorSearchAttachController.php index 0218e8658f..b6519a3e0b 100644 --- a/src/applications/search/controller/PhabricatorSearchAttachController.php +++ b/src/applications/search/controller/PhabricatorSearchAttachController.php @@ -290,10 +290,10 @@ final class PhabricatorSearchAttachController $map = array( $t_cmit => array( - $t_task => PhabricatorEdgeConfig::TYPE_COMMIT_HAS_TASK, + $t_task => DiffusionCommitHasTaskEdgeType::EDGECONST, ), $t_task => array( - $t_cmit => PhabricatorEdgeConfig::TYPE_TASK_HAS_COMMIT, + $t_cmit => ManiphestTaskHasCommitEdgeType::EDGECONST, $t_task => PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK, $t_drev => ManiphestTaskHasRevisionEdgeType::EDGECONST, $t_mock => PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK, diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index bfff37a813..8bcd37efb0 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -5,9 +5,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { const TABLE_NAME_EDGE = 'edge'; const TABLE_NAME_EDGEDATA = 'edgedata'; - const TYPE_TASK_HAS_COMMIT = 1; - const TYPE_COMMIT_HAS_TASK = 2; - const TYPE_TASK_DEPENDS_ON_TASK = 3; const TYPE_TASK_DEPENDED_ON_BY_TASK = 4; @@ -136,9 +133,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { private static function getInverse($edge_type) { static $map = array( - self::TYPE_TASK_HAS_COMMIT => self::TYPE_COMMIT_HAS_TASK, - self::TYPE_COMMIT_HAS_TASK => self::TYPE_TASK_HAS_COMMIT, - self::TYPE_TASK_DEPENDS_ON_TASK => self::TYPE_TASK_DEPENDED_ON_BY_TASK, self::TYPE_TASK_DEPENDED_ON_BY_TASK => self::TYPE_TASK_DEPENDS_ON_TASK, @@ -259,11 +253,9 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { public static function getEditStringForEdgeType($type) { switch ($type) { - case self::TYPE_TASK_HAS_COMMIT: case self::TYPE_PROJECT_HAS_COMMIT: case self::TYPE_DREV_HAS_COMMIT: return '%s edited commit(s), added %d: %s; removed %d: %s.'; - case self::TYPE_COMMIT_HAS_TASK: case self::TYPE_TASK_DEPENDS_ON_TASK: case self::TYPE_TASK_DEPENDED_ON_BY_TASK: case self::TYPE_MOCK_HAS_TASK: @@ -335,7 +327,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { public static function getAddStringForEdgeType($type) { switch ($type) { - case self::TYPE_TASK_HAS_COMMIT: case self::TYPE_PROJECT_HAS_COMMIT: case self::TYPE_DREV_HAS_COMMIT: return '%s added %d commit(s): %s.'; @@ -345,7 +336,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { return '%s added %d dependencie(s): %s.'; case self::TYPE_TASK_DEPENDED_ON_BY_TASK: return '%s added %d blocked task(s): %s.'; - case self::TYPE_COMMIT_HAS_TASK: case self::TYPE_MOCK_HAS_TASK: return '%s added %d task(s): %s.'; case self::TYPE_DREV_DEPENDED_ON_BY_DREV: @@ -413,7 +403,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { public static function getRemoveStringForEdgeType($type) { switch ($type) { - case self::TYPE_TASK_HAS_COMMIT: case self::TYPE_PROJECT_HAS_COMMIT: case self::TYPE_DREV_HAS_COMMIT: return '%s removed %d commit(s): %s.'; @@ -421,7 +410,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { return '%s removed %d blocking task(s): %s.'; case self::TYPE_TASK_DEPENDED_ON_BY_TASK: return '%s removed %d blocked task(s): %s.'; - case self::TYPE_COMMIT_HAS_TASK: case self::TYPE_MOCK_HAS_TASK: return '%s removed %d task(s): %s.'; case self::TYPE_DREV_DEPENDS_ON_DREV: @@ -488,11 +476,9 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { public static function getFeedStringForEdgeType($type) { switch ($type) { - case self::TYPE_TASK_HAS_COMMIT: case self::TYPE_PROJECT_HAS_COMMIT: case self::TYPE_DREV_HAS_COMMIT: return '%s updated commits of %s.'; - case self::TYPE_COMMIT_HAS_TASK: case self::TYPE_TASK_DEPENDS_ON_TASK: case self::TYPE_TASK_DEPENDED_ON_BY_TASK: case self::TYPE_MOCK_HAS_TASK: From 33120e377a634eff48d79f2f6dfcc67cf0bbba29 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:42:19 -0700 Subject: [PATCH 11/44] Modernize Project/Object edges Summary: Ref T5245. Updates the project/object edge to use a modern class definition. Moves further toward real edges. Test Plan: Added projects to some objects, viewed transactions in transaction record. Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9849 --- src/__phutil_library_map__.php | 4 + .../customfield/DifferentialProjectsField.php | 6 +- .../DiffusionRepositoryController.php | 2 +- ...DiffusionRepositoryEditBasicController.php | 2 +- .../DiffusionRepositoryEditMainController.php | 2 +- .../adapter/HeraldPholioMockAdapter.php | 2 +- .../PhabricatorPasteEditController.php | 4 +- .../controller/PholioMockEditController.php | 4 +- .../PonderQuestionEditController.php | 4 +- ...ricatorProjectObjectHasProjectEdgeType.php | 102 ++++++++++++++++++ ...ricatorProjectProjectHasObjectEdgeType.php | 12 +++ .../PhabricatorProjectUIEventListener.php | 2 +- .../query/PhabricatorRepositoryQuery.php | 2 +- .../PhabricatorSlowvoteEditController.php | 4 +- ...habricatorApplicationTransactionEditor.php | 4 +- .../edges/constants/PhabricatorEdgeConfig.php | 14 --- 16 files changed, 138 insertions(+), 32 deletions(-) create mode 100644 src/applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php create mode 100644 src/applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e0ccee3f2d..6718dc6a72 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2008,9 +2008,11 @@ phutil_register_library_map(array( 'PhabricatorProjectMembersRemoveController' => 'applications/project/controller/PhabricatorProjectMembersRemoveController.php', 'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php', 'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php', + 'PhabricatorProjectObjectHasProjectEdgeType' => 'applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php', 'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php', 'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php', 'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php', + 'PhabricatorProjectProjectHasObjectEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php', 'PhabricatorProjectQuery' => 'applications/project/query/PhabricatorProjectQuery.php', 'PhabricatorProjectSearchEngine' => 'applications/project/query/PhabricatorProjectSearchEngine.php', 'PhabricatorProjectSearchIndexer' => 'applications/project/search/PhabricatorProjectSearchIndexer.php', @@ -4820,9 +4822,11 @@ phutil_register_library_map(array( 'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController', 'PhabricatorProjectMoveController' => 'PhabricatorProjectController', 'PhabricatorProjectNameCollisionException' => 'Exception', + 'PhabricatorProjectObjectHasProjectEdgeType' => 'PhabricatorEdgeType', 'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType', 'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType', 'PhabricatorProjectProfileController' => 'PhabricatorProjectController', + 'PhabricatorProjectProjectHasObjectEdgeType' => 'PhabricatorEdgeType', 'PhabricatorProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorProjectSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer', diff --git a/src/applications/differential/customfield/DifferentialProjectsField.php b/src/applications/differential/customfield/DifferentialProjectsField.php index 461c60b1b2..72762bee69 100644 --- a/src/applications/differential/customfield/DifferentialProjectsField.php +++ b/src/applications/differential/customfield/DifferentialProjectsField.php @@ -35,7 +35,7 @@ final class DifferentialProjectsField $projects = PhabricatorEdgeQuery::loadDestinationPHIDs( $revision->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $projects = array_reverse($projects); return $projects; @@ -97,7 +97,9 @@ final class DifferentialProjectsField } public function getApplicationTransactionMetadata() { - return array('edge:type' => PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + return array( + 'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, + ); } public function parseValueFromCommitMessage($value) { diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php index 151c5f8a2c..9d26926345 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php @@ -231,7 +231,7 @@ final class DiffusionRepositoryController extends DiffusionController { $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $repository->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); if ($project_phids) { $this->loadHandles($project_phids); $view->addProperty( diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php index 7fa932f551..1f6bb5acc1 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php @@ -73,7 +73,7 @@ final class DiffusionRepositoryEditBasicController ->setTransactionType($type_edge) ->setMetadataValue( 'edge:type', - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT) + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST) ->setNewValue( array( '=' => array_fuse($v_projects), diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php index 0d2fd486f9..85c611bfb1 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php @@ -265,7 +265,7 @@ final class DiffusionRepositoryEditMainController $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $repository->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); if ($project_phids) { $this->loadHandles($project_phids); $project_text = $this->renderHandlesForPHIDs($project_phids); diff --git a/src/applications/herald/adapter/HeraldPholioMockAdapter.php b/src/applications/herald/adapter/HeraldPholioMockAdapter.php index b3da0c63e3..26c1b0327e 100644 --- a/src/applications/herald/adapter/HeraldPholioMockAdapter.php +++ b/src/applications/herald/adapter/HeraldPholioMockAdapter.php @@ -103,7 +103,7 @@ final class HeraldPholioMockAdapter extends HeraldAdapter { case self::FIELD_PROJECTS: return PhabricatorEdgeQuery::loadDestinationPHIDs( $this->getMock()->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } return parent::getHeraldField($field); diff --git a/src/applications/paste/controller/PhabricatorPasteEditController.php b/src/applications/paste/controller/PhabricatorPasteEditController.php index a15f4a3af5..878b567a36 100644 --- a/src/applications/paste/controller/PhabricatorPasteEditController.php +++ b/src/applications/paste/controller/PhabricatorPasteEditController.php @@ -76,7 +76,7 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController { } else { $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs( $paste->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $v_projects = array_reverse($v_projects); } @@ -121,7 +121,7 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController { ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) ->setNewValue($v_policy); - $proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT; + $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xactions[] = id(new PhabricatorPasteTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $proj_edge_type) diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php index 669c0fc1a8..5a9024a30f 100644 --- a/src/applications/pholio/controller/PholioMockEditController.php +++ b/src/applications/pholio/controller/PholioMockEditController.php @@ -49,7 +49,7 @@ final class PholioMockEditController extends PholioController { } else { $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs( $mock->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $v_projects = array_reverse($v_projects); } @@ -205,7 +205,7 @@ final class PholioMockEditController extends PholioController { } if (!$errors) { - $proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT; + $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xactions[] = id(new PholioTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $proj_edge_type) diff --git a/src/applications/ponder/controller/PonderQuestionEditController.php b/src/applications/ponder/controller/PonderQuestionEditController.php index 55bfb75d5b..557c2c8910 100644 --- a/src/applications/ponder/controller/PonderQuestionEditController.php +++ b/src/applications/ponder/controller/PonderQuestionEditController.php @@ -27,7 +27,7 @@ final class PonderQuestionEditController extends PonderController { } $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs( $question->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $v_projects = array_reverse($v_projects); } else { $question = id(new PonderQuestion()) @@ -70,7 +70,7 @@ final class PonderQuestionEditController extends PonderController { ->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT) ->setNewValue($v_content); - $proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT; + $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xactions[] = id(new PonderQuestionTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $proj_edge_type) diff --git a/src/applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php b/src/applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php new file mode 100644 index 0000000000..789a3cbba5 --- /dev/null +++ b/src/applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php @@ -0,0 +1,102 @@ +getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); if ($project_phids) { $project_phids = array_reverse($project_phids); $handles = id(new PhabricatorHandleQuery()) diff --git a/src/applications/repository/query/PhabricatorRepositoryQuery.php b/src/applications/repository/query/PhabricatorRepositoryQuery.php index 23d2911dc1..8423adf486 100644 --- a/src/applications/repository/query/PhabricatorRepositoryQuery.php +++ b/src/applications/repository/query/PhabricatorRepositoryQuery.php @@ -208,7 +208,7 @@ final class PhabricatorRepositoryQuery public function didFilterPage(array $repositories) { if ($this->needProjectPHIDs) { - $type_project = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT; + $type_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $edge_query = id(new PhabricatorEdgeQuery()) ->withSourcePHIDs(mpull($repositories, 'getPHID')) diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php index 1f2766a43b..57e18d760f 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php @@ -38,7 +38,7 @@ final class PhabricatorSlowvoteEditController } else { $v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs( $poll->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); $v_projects = array_reverse($v_projects); } @@ -105,7 +105,7 @@ final class PhabricatorSlowvoteEditController ->setNewValue($v_view_policy); if (empty($errors)) { - $proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT; + $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xactions[] = id(new PhabricatorSlowvoteTransaction()) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $proj_edge_type) diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 863814f66b..c7426e2269 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1153,7 +1153,7 @@ abstract class PhabricatorApplicationTransactionEditor } if ($phids) { - $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT; + $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $block_xactions[] = newv(get_class(head($xactions)), array()) ->setIgnoreOnNoEffect(true) ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) @@ -1967,7 +1967,7 @@ abstract class PhabricatorApplicationTransactionEditor if ($object instanceof PhabricatorProjectInterface) { $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $object->getPHID(), - PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT); + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } else { $project_phids = $object->getProjectPHIDs(); } diff --git a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php index 8bcd37efb0..057af62689 100644 --- a/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php +++ b/src/infrastructure/edges/constants/PhabricatorEdgeConfig.php @@ -57,9 +57,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { const TYPE_OBJECT_USES_CREDENTIAL = 39; const TYPE_CREDENTIAL_USED_BY_OBJECT = 40; - const TYPE_OBJECT_HAS_PROJECT = 41; - const TYPE_PROJECT_HAS_OBJECT = 42; - const TYPE_OBJECT_HAS_COLUMN = 43; const TYPE_COLUMN_HAS_OBJECT = 44; @@ -193,9 +190,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { self::TYPE_OBJECT_USES_CREDENTIAL => self::TYPE_CREDENTIAL_USED_BY_OBJECT, self::TYPE_CREDENTIAL_USED_BY_OBJECT => self::TYPE_OBJECT_USES_CREDENTIAL, - self::TYPE_OBJECT_HAS_PROJECT => self::TYPE_PROJECT_HAS_OBJECT, - self::TYPE_PROJECT_HAS_OBJECT => self::TYPE_OBJECT_HAS_PROJECT, - self::TYPE_OBJECT_HAS_COLUMN => self::TYPE_COLUMN_HAS_OBJECT, self::TYPE_COLUMN_HAS_OBJECT => self::TYPE_OBJECT_HAS_COLUMN, @@ -276,7 +270,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { return '%s edited member(s), added %d: %s; removed %d: %s.'; case self::TYPE_MEMBER_OF_PROJ: case self::TYPE_COMMIT_HAS_PROJECT: - case self::TYPE_OBJECT_HAS_PROJECT: return '%s edited project(s), added %d: %s; removed %d: %s.'; case self::TYPE_QUESTION_HAS_VOTING_USER: case self::TYPE_ANSWER_HAS_VOTING_USER: @@ -291,7 +284,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { case self::TYPE_UNSUBSCRIBED_FROM_OBJECT: case self::TYPE_FILE_HAS_OBJECT: case self::TYPE_CONTRIBUTED_TO_OBJECT: - case self::TYPE_PROJECT_HAS_OBJECT: return '%s edited object(s), added %d: %s; removed %d: %s.'; case self::TYPE_OBJECT_HAS_UNSUBSCRIBER: return '%s edited unsubcriber(s), added %d: %s; removed %d: %s.'; @@ -353,7 +345,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { return '%s added %d member(s): %s.'; case self::TYPE_MEMBER_OF_PROJ: case self::TYPE_COMMIT_HAS_PROJECT: - case self::TYPE_OBJECT_HAS_PROJECT: return '%s added %d project(s): %s.'; case self::TYPE_QUESTION_HAS_VOTING_USER: case self::TYPE_ANSWER_HAS_VOTING_USER: @@ -394,7 +385,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { case self::TYPE_UNSUBSCRIBED_FROM_OBJECT: case self::TYPE_FILE_HAS_OBJECT: case self::TYPE_CONTRIBUTED_TO_OBJECT: - case self::TYPE_PROJECT_HAS_OBJECT: default: return '%s added %d object(s): %s.'; @@ -428,7 +418,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { return '%s removed %d member(s): %s.'; case self::TYPE_MEMBER_OF_PROJ: case self::TYPE_COMMIT_HAS_PROJECT: - case self::TYPE_OBJECT_HAS_PROJECT: return '%s removed %d project(s): %s.'; case self::TYPE_QUESTION_HAS_VOTING_USER: case self::TYPE_ANSWER_HAS_VOTING_USER: @@ -467,7 +456,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { case self::TYPE_UNSUBSCRIBED_FROM_OBJECT: case self::TYPE_FILE_HAS_OBJECT: case self::TYPE_CONTRIBUTED_TO_OBJECT: - case self::TYPE_PROJECT_HAS_OBJECT: default: return '%s removed %d object(s): %s.'; @@ -499,7 +487,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { return '%s updated members of %s.'; case self::TYPE_MEMBER_OF_PROJ: case self::TYPE_COMMIT_HAS_PROJECT: - case self::TYPE_OBJECT_HAS_PROJECT: return '%s updated projects of %s.'; case self::TYPE_QUESTION_HAS_VOTING_USER: case self::TYPE_ANSWER_HAS_VOTING_USER: @@ -538,7 +525,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants { case self::TYPE_UNSUBSCRIBED_FROM_OBJECT: case self::TYPE_FILE_HAS_OBJECT: case self::TYPE_CONTRIBUTED_TO_OBJECT: - case self::TYPE_PROJECT_HAS_OBJECT: default: return '%s updated objects of %s.'; From aa79539789752a799c1c6b98788cb423ecfdd0b6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:42:30 -0700 Subject: [PATCH 12/44] Move task/project storage to edges Summary: Ref T5245. This moves the actual storage over and stops reads and writes to the old table. Test Plan: - Verified tasks retained projects across the migration. - Added and removed projects from tasks. - Searched for: all, any, users' projects, not-in-projects, no-projects. Reviewers: chad, btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9850 --- .../sql/autopatches/20140706.pedge.1.sql | 10 ++++ .../controller/ManiphestReportController.php | 5 +- .../maniphest/query/ManiphestTaskQuery.php | 52 +++++++++++-------- .../storage/ManiphestTaskProject.php | 39 +++++++------- 4 files changed, 63 insertions(+), 43 deletions(-) create mode 100644 resources/sql/autopatches/20140706.pedge.1.sql diff --git a/resources/sql/autopatches/20140706.pedge.1.sql b/resources/sql/autopatches/20140706.pedge.1.sql new file mode 100644 index 0000000000..3dd049105c --- /dev/null +++ b/resources/sql/autopatches/20140706.pedge.1.sql @@ -0,0 +1,10 @@ +/* PhabricatorProjectObjectHasProjectEdgeType::EDGECONST = 41 */ +/* PhabricatorProjectProjectHasObjectEdgeType::EDGECONST = 42 */ + +INSERT IGNORE INTO {$NAMESPACE}_maniphest.edge (src, type, dst) + SELECT taskPHID, 41, projectPHID + FROM {$NAMESPACE}_maniphest.maniphest_taskproject; + +INSERT IGNORE INTO {$NAMESPACE}_project.edge (src, type, dst) + SELECT projectPHID, 42, taskPHID + FROM {$NAMESPACE}_maniphest.maniphest_taskproject; diff --git a/src/applications/maniphest/controller/ManiphestReportController.php b/src/applications/maniphest/controller/ManiphestReportController.php index 00b00d81b5..6fd69d432c 100644 --- a/src/applications/maniphest/controller/ManiphestReportController.php +++ b/src/applications/maniphest/controller/ManiphestReportController.php @@ -83,9 +83,10 @@ final class ManiphestReportController extends ManiphestController { $joins = qsprintf( $conn, 'JOIN %T t ON x.objectPHID = t.phid - JOIN %T p ON p.taskPHID = t.phid AND p.projectPHID = %s', + JOIN %T p ON p.src = t.phid AND p.type = %d AND p.dst = %s', id(new ManiphestTask())->getTableName(), - id(new ManiphestTaskProject())->getTableName(), + PhabricatorEdgeConfig::TABLE_NAME_EDGE, + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, $project_phid); } diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php index 1b29705493..7e7616c0c8 100644 --- a/src/applications/maniphest/query/ManiphestTaskQuery.php +++ b/src/applications/maniphest/query/ManiphestTaskQuery.php @@ -243,7 +243,7 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { // query. We sum the project count and require it be the same as the // number of projects we're searching for. - $count = ', COUNT(project.projectPHID) projectCount'; + $count = ', COUNT(project.dst) projectCount'; $having = qsprintf( $conn, 'HAVING projectCount = %d', @@ -496,13 +496,13 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { if ($this->projectPHIDs) { $parts[] = qsprintf( $conn, - 'project.projectPHID in (%Ls)', + 'project.dst in (%Ls)', $this->projectPHIDs); } if ($this->includeNoProject) { $parts[] = qsprintf( $conn, - 'project.projectPHID IS NULL'); + 'project.dst IS NULL'); } return '('.implode(') OR (', $parts).')'; @@ -515,7 +515,7 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { return qsprintf( $conn, - 'anyproject.projectPHID IN (%Ls)', + 'anyproject.dst IN (%Ls)', $this->anyProjectPHIDs); } @@ -536,7 +536,7 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { return qsprintf( $conn, - 'anyproject.projectPHID IN (%Ls)', + 'anyproject.dst IN (%Ls)', $any_user_project_phids); } @@ -547,7 +547,7 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { return qsprintf( $conn, - 'xproject.projectPHID IS NULL'); + 'xproject.dst IS NULL'); } private function buildCustomOrderClause(AphrontDatabaseConnection $conn) { @@ -636,31 +636,37 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { } private function buildJoinsClause(AphrontDatabaseConnection $conn_r) { - $project_dao = new ManiphestTaskProject(); + $edge_table = PhabricatorEdgeConfig::TABLE_NAME_EDGE; $joins = array(); if ($this->projectPHIDs || $this->includeNoProject) { $joins[] = qsprintf( $conn_r, - '%Q JOIN %T project ON project.taskPHID = task.phid', + '%Q JOIN %T project ON project.src = task.phid + AND project.type = %d', ($this->includeNoProject ? 'LEFT' : ''), - $project_dao->getTableName()); + $edge_table, + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } if ($this->anyProjectPHIDs || $this->anyUserProjectPHIDs) { $joins[] = qsprintf( $conn_r, - 'JOIN %T anyproject ON anyproject.taskPHID = task.phid', - $project_dao->getTableName()); + 'JOIN %T anyproject ON anyproject.src = task.phid + AND anyproject.type = %d', + $edge_table, + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } if ($this->xprojectPHIDs) { $joins[] = qsprintf( $conn_r, - 'LEFT JOIN %T xproject ON xproject.taskPHID = task.phid - AND xproject.projectPHID IN (%Ls)', - $project_dao->getTableName(), + 'LEFT JOIN %T xproject ON xproject.src = task.phid + AND xproject.type = %d + AND xproject.dst IN (%Ls)', + $edge_table, + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, $this->xprojectPHIDs); } @@ -678,20 +684,24 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { if ($ignore_group_phids) { $joins[] = qsprintf( $conn_r, - 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.taskPHID - AND projectGroup.projectPHID NOT IN (%Ls)', - $project_dao->getTableName(), + 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.src + AND projectGroup.type = %d + AND projectGroup.dst NOT IN (%Ls)', + $edge_table, + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, $ignore_group_phids); } else { $joins[] = qsprintf( $conn_r, - 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.taskPHID', - $project_dao->getTableName()); + 'LEFT JOIN %T projectGroup ON task.phid = projectGroup.src + AND projectGroup.type = %d', + $edge_table, + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); } $joins[] = qsprintf( $conn_r, 'LEFT JOIN %T projectGroupName - ON projectGroup.projectPHID = projectGroupName.indexedObjectPHID', + ON projectGroup.dst = projectGroupName.indexedObjectPHID', id(new ManiphestNameIndex())->getTableName()); break; } @@ -712,7 +722,7 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { // task IDs. if ($joined_multiple_rows) { if ($joined_project_name) { - return 'GROUP BY task.phid, projectGroup.projectPHID'; + return 'GROUP BY task.phid, projectGroup.dst'; } else { return 'GROUP BY task.phid'; } diff --git a/src/applications/maniphest/storage/ManiphestTaskProject.php b/src/applications/maniphest/storage/ManiphestTaskProject.php index f26627a01b..eda914579b 100644 --- a/src/applications/maniphest/storage/ManiphestTaskProject.php +++ b/src/applications/maniphest/storage/ManiphestTaskProject.php @@ -20,30 +20,29 @@ final class ManiphestTaskProject extends ManiphestDAO { } public static function updateTaskProjects(ManiphestTask $task) { - $dao = new ManiphestTaskProject(); - $conn = $dao->establishConnection('w'); + $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; - $sql = array(); - foreach ($task->getProjectPHIDs() as $project_phid) { - $sql[] = qsprintf( - $conn, - '(%s, %s)', - $task->getPHID(), - $project_phid); + $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( + $task->getPHID(), + $edge_type); + $new_phids = $task->getProjectPHIDs(); + + $add_phids = array_diff($new_phids, $old_phids); + $rem_phids = array_diff($old_phids, $new_phids); + + if (!$add_phids && !$rem_phids) { + return; } - queryfx( - $conn, - 'DELETE FROM %T WHERE taskPHID = %s', - $dao->getTableName(), - $task->getPHID()); - if ($sql) { - queryfx( - $conn, - 'INSERT INTO %T (taskPHID, projectPHID) VALUES %Q', - $dao->getTableName(), - implode(', ', $sql)); + + $editor = new PhabricatorEdgeEditor(); + foreach ($add_phids as $phid) { + $editor->addEdge($task->getPHID(), $edge_type, $phid); } + foreach ($rem_phids as $phid) { + $editor->remEdge($task->getPHID(), $edge_type, $phid); + } + $editor->save(); } } From b8b59895eeeceefa3a7ed56e593dcad455f5a1ae Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:42:53 -0700 Subject: [PATCH 13/44] Stop reads and writes to projectPHIDs property on ManiphestTask Summary: Ref T5245. This property predates edges and is unusual in modern applications. Stop writes to it and populate it implicitly from edges when querying. Test Plan: - Viewed task list. - Created a task. - Added and removed projects from tasks. Reviewers: joshuaspence, chad, btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9851 --- .../ManiphestTaskEditController.php | 6 +++--- .../editor/ManiphestTransactionEditor.php | 5 +++-- .../maniphest/query/ManiphestTaskQuery.php | 21 +++++++++++++++++++ .../maniphest/storage/ManiphestTask.php | 14 +++++++------ .../storage/ManiphestTaskProject.php | 7 ++++--- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index a4c13242b0..ad7e306c36 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -81,7 +81,7 @@ final class ManiphestTaskEditController extends ManiphestController { $default_projects = mpull($default_projects, 'getPHID'); if ($default_projects) { - $task->setProjectPHIDs($default_projects); + $task->attachProjectPHIDs($default_projects); } } } @@ -215,7 +215,7 @@ final class ManiphestTaskEditController extends ManiphestController { $task->setPriority($request->getInt('priority')); $task->setOwnerPHID($owner_phid); $task->setCCPHIDs($request->getArr('cc')); - $task->setProjectPHIDs($request->getArr('projects')); + $task->attachProjectPHIDs($request->getArr('projects')); } else { if ($can_edit_priority) { @@ -438,7 +438,7 @@ final class ManiphestTaskEditController extends ManiphestController { ->executeOne(); if ($template_task) { $task->setCCPHIDs($template_task->getCCPHIDs()); - $task->setProjectPHIDs($template_task->getProjectPHIDs()); + $task->attachProjectPHIDs($template_task->getProjectPHIDs()); $task->setOwnerPHID($template_task->getOwnerPHID()); $task->setPriority($template_task->getPriority()); $task->setViewPolicy($template_task->getViewPolicy()); diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index 5ed423bc74..d7abddbcd1 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -150,8 +150,9 @@ final class ManiphestTransactionEditor case ManiphestTransaction::TYPE_CCS: return $object->setCCPHIDs($xaction->getNewValue()); case ManiphestTransaction::TYPE_PROJECTS: - $object->setProjectPHIDs($xaction->getNewValue()); - ManiphestTaskProject::updateTaskProjects($object); + ManiphestTaskProject::updateTaskProjects( + $object, + $xaction->getNewValue()); return $object; case ManiphestTransaction::TYPE_SUBPRIORITY: $data = $xaction->getNewValue(); diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php index 7e7616c0c8..5c1d17bc8f 100644 --- a/src/applications/maniphest/query/ManiphestTaskQuery.php +++ b/src/applications/maniphest/query/ManiphestTaskQuery.php @@ -331,6 +331,27 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { return $tasks; } + protected function didFilterPage(array $tasks) { + // TODO: Eventually, we should make this optional and introduce a + // needProjectPHIDs() method, but for now there's a lot of code which + // assumes the data is always populated. + + $edge_query = id(new PhabricatorEdgeQuery()) + ->withSourcePHIDs(mpull($tasks, 'getPHID')) + ->withEdgeTypes( + array( + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, + )); + $edge_query->execute(); + + foreach ($tasks as $task) { + $phids = $edge_query->getDestinationPHIDs(array($task->getPHID())); + $task->attachProjectPHIDs($phids); + } + + return $tasks; + } + private function buildTaskIDsWhereClause(AphrontDatabaseConnection $conn) { if (!$this->taskIDs) { return null; diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index 9f9d9ca26e..fbba84c01c 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -37,6 +37,7 @@ final class ManiphestTask extends ManiphestDAO private $groupByProjectPHID = self::ATTACHABLE; private $customFields = self::ATTACHABLE; + private $edgeProjectPHIDs = self::ATTACHABLE; public static function initializeNewTask(PhabricatorUser $actor) { $app = id(new PhabricatorApplicationQuery()) @@ -52,7 +53,8 @@ final class ManiphestTask extends ManiphestDAO ->setPriority(ManiphestTaskPriority::getDefaultPriority()) ->setAuthorPHID($actor->getPHID()) ->setViewPolicy($view_policy) - ->setEditPolicy($edit_policy); + ->setEditPolicy($edit_policy) + ->attachProjectPHIDs(array()); } public function getConfiguration() { @@ -90,13 +92,13 @@ final class ManiphestTask extends ManiphestDAO return array_values(nonempty($this->ccPHIDs, array())); } - public function setProjectPHIDs(array $phids) { - $this->projectPHIDs = array_values($phids); - return $this; + public function getProjectPHIDs() { + return $this->assertAttached($this->edgeProjectPHIDs); } - public function getProjectPHIDs() { - return array_values(nonempty($this->projectPHIDs, array())); + public function attachProjectPHIDs(array $phids) { + $this->edgeProjectPHIDs = $phids; + return $this; } public function setCCPHIDs(array $phids) { diff --git a/src/applications/maniphest/storage/ManiphestTaskProject.php b/src/applications/maniphest/storage/ManiphestTaskProject.php index eda914579b..d5d002466b 100644 --- a/src/applications/maniphest/storage/ManiphestTaskProject.php +++ b/src/applications/maniphest/storage/ManiphestTaskProject.php @@ -19,13 +19,15 @@ final class ManiphestTaskProject extends ManiphestDAO { ); } - public static function updateTaskProjects(ManiphestTask $task) { + public static function updateTaskProjects( + ManiphestTask $task, + array $new_phids) { + $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( $task->getPHID(), $edge_type); - $new_phids = $task->getProjectPHIDs(); $add_phids = array_diff($new_phids, $old_phids); $rem_phids = array_diff($old_phids, $new_phids); @@ -34,7 +36,6 @@ final class ManiphestTaskProject extends ManiphestDAO { return; } - $editor = new PhabricatorEdgeEditor(); foreach ($add_phids as $phid) { $editor->addEdge($task->getPHID(), $edge_type, $phid); From e8c490958c8a2584c5d2dee5431fb34b4776c626 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:43:40 -0700 Subject: [PATCH 14/44] Stop writing new TYPE_PROJECTS transactions to Maniphest Summary: Ref T5245. We'll still display the old ones, but write real edge transactions now -- not TYPE_PROJECTS transactions. Some code remains to show the existing transactions. The next diff will modernize the old transactions so we can remove this code. Test Plan: - Previewed a project-editing comment. - Submitted a project-editing comment. - Edited a task's projects. - Batch edited a task's projects. Reviewers: joshuaspence, chad, btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9852 --- src/__phutil_library_map__.php | 2 - .../conduit/ConduitAPI_maniphest_Method.php | 13 ++++- .../ManiphestBatchEditController.php | 12 +++++ .../ManiphestTaskEditController.php | 11 +++++ .../ManiphestTransactionPreviewController.php | 15 ++++-- .../ManiphestTransactionSaveController.php | 11 ++++- .../editor/ManiphestTransactionEditor.php | 40 +++++++-------- ...bricatorManiphestTaskTestDataGenerator.php | 2 - .../storage/ManiphestTaskProject.php | 49 ------------------- .../storage/ManiphestTransaction.php | 11 ++++- 10 files changed, 82 insertions(+), 84 deletions(-) delete mode 100644 src/applications/maniphest/storage/ManiphestTaskProject.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 6718dc6a72..fec80ea1af 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -954,7 +954,6 @@ phutil_register_library_map(array( 'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php', 'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php', 'ManiphestTaskPriorityDatasource' => 'applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php', - 'ManiphestTaskProject' => 'applications/maniphest/storage/ManiphestTaskProject.php', 'ManiphestTaskQuery' => 'applications/maniphest/query/ManiphestTaskQuery.php', 'ManiphestTaskResultListView' => 'applications/maniphest/view/ManiphestTaskResultListView.php', 'ManiphestTaskSearchEngine' => 'applications/maniphest/query/ManiphestTaskSearchEngine.php', @@ -3716,7 +3715,6 @@ phutil_register_library_map(array( 'ManiphestTaskOwner' => 'ManiphestConstants', 'ManiphestTaskPriority' => 'ManiphestConstants', 'ManiphestTaskPriorityDatasource' => 'PhabricatorTypeaheadDatasource', - 'ManiphestTaskProject' => 'ManiphestDAO', 'ManiphestTaskQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ManiphestTaskResultListView' => 'ManiphestView', 'ManiphestTaskSearchEngine' => 'PhabricatorApplicationSearchEngine', diff --git a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php index b2dd625bfc..d45c42dc88 100644 --- a/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php +++ b/src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php @@ -116,18 +116,27 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod { $changes[ManiphestTransaction::TYPE_CCS] = $ccs; } + $transactions = array(); + $project_phids = $request->getValue('projectPHIDs'); if ($project_phids !== null) { $this->validatePHIDList( $project_phids, PhabricatorProjectPHIDTypeProject::TYPECONST, 'projectPHIDS'); - $changes[ManiphestTransaction::TYPE_PROJECTS] = $project_phids; + + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; + $transactions[] = id(new ManiphestTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $project_type) + ->setNewValue( + array( + '=' => array_fuse($project_phids), + )); } $template = new ManiphestTransaction(); - $transactions = array(); foreach ($changes as $type => $value) { $transaction = clone $template; $transaction->setTransactionType($type); diff --git a/src/applications/maniphest/controller/ManiphestBatchEditController.php b/src/applications/maniphest/controller/ManiphestBatchEditController.php index fbcb84884b..5dfaba42f3 100644 --- a/src/applications/maniphest/controller/ManiphestBatchEditController.php +++ b/src/applications/maniphest/controller/ManiphestBatchEditController.php @@ -324,6 +324,18 @@ final class ManiphestBatchEditController extends ManiphestController { id(new ManiphestTransactionComment()) ->setContent($value)); break; + case ManiphestTransaction::TYPE_PROJECTS: + + // TODO: Clean this mess up. + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; + $xaction + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $project_type) + ->setNewValue( + array( + '=' => array_fuse($value), + )); + break; default: $xaction->setNewValue($value); break; diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index ad7e306c36..de6b272068 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -269,6 +269,17 @@ final class ManiphestTaskEditController extends ManiphestController { if ($type == ManiphestTransaction::TYPE_PROJECT_COLUMN) { $transaction->setNewValue($value['new']); $transaction->setOldValue($value['old']); + } else if ($type == ManiphestTransaction::TYPE_PROJECTS) { + // TODO: Gross. + $project_type = + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; + $transaction + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $project_type) + ->setNewValue( + array( + '=' => array_fuse($value), + )); } else { $transaction->setNewValue($value); } diff --git a/src/applications/maniphest/controller/ManiphestTransactionPreviewController.php b/src/applications/maniphest/controller/ManiphestTransactionPreviewController.php index 75f75c49bc..ac2b8a861a 100644 --- a/src/applications/maniphest/controller/ManiphestTransactionPreviewController.php +++ b/src/applications/maniphest/controller/ManiphestTransactionPreviewController.php @@ -83,14 +83,19 @@ final class ManiphestTransactionPreviewController extends ManiphestController { $value = array(); } - $phids = $value; - foreach ($task->getProjectPHIDs() as $project_phid) { + $phids = array(); + $value = array_fuse($value); + foreach ($value as $project_phid) { $phids[] = $project_phid; - $value[] = $project_phid; + $value[$project_phid] = array('dst' => $project_phid); } - $transaction->setOldValue($task->getProjectPHIDs()); - $transaction->setNewValue($value); + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; + $transaction + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $project_type) + ->setOldValue(array()) + ->setNewValue($value); break; case ManiphestTransaction::TYPE_STATUS: $phids = array(); diff --git a/src/applications/maniphest/controller/ManiphestTransactionSaveController.php b/src/applications/maniphest/controller/ManiphestTransactionSaveController.php index 34e2f57f37..a11149982b 100644 --- a/src/applications/maniphest/controller/ManiphestTransactionSaveController.php +++ b/src/applications/maniphest/controller/ManiphestTransactionSaveController.php @@ -53,7 +53,16 @@ final class ManiphestTransactionSaveController extends ManiphestController { $projects = array_merge($projects, $task->getProjectPHIDs()); $projects = array_filter($projects); $projects = array_unique($projects); - $transaction->setNewValue($projects); + + // TODO: Bleh. + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; + $transaction + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $project_type) + ->setNewValue( + array( + '+' => array_fuse($projects), + )); break; case ManiphestTransaction::TYPE_CCS: // Accumulate the new explicit CCs into the array that we'll add in diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index d7abddbcd1..58f3d5cda8 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -16,7 +16,6 @@ final class ManiphestTransactionEditor $types[] = ManiphestTransaction::TYPE_DESCRIPTION; $types[] = ManiphestTransaction::TYPE_OWNER; $types[] = ManiphestTransaction::TYPE_CCS; - $types[] = ManiphestTransaction::TYPE_PROJECTS; $types[] = ManiphestTransaction::TYPE_SUBPRIORITY; $types[] = ManiphestTransaction::TYPE_PROJECT_COLUMN; $types[] = ManiphestTransaction::TYPE_UNBLOCK; @@ -55,8 +54,6 @@ final class ManiphestTransactionEditor return nonempty($object->getOwnerPHID(), null); case ManiphestTransaction::TYPE_CCS: return array_values(array_unique($object->getCCPHIDs())); - case ManiphestTransaction::TYPE_PROJECTS: - return array_values(array_unique($object->getProjectPHIDs())); case ManiphestTransaction::TYPE_PROJECT_COLUMN: // These are pre-populated. return $xaction->getOldValue(); @@ -74,7 +71,6 @@ final class ManiphestTransactionEditor case ManiphestTransaction::TYPE_PRIORITY: return (int)$xaction->getNewValue(); case ManiphestTransaction::TYPE_CCS: - case ManiphestTransaction::TYPE_PROJECTS: return array_values(array_unique($xaction->getNewValue())); case ManiphestTransaction::TYPE_OWNER: return nonempty($xaction->getNewValue(), null); @@ -97,7 +93,6 @@ final class ManiphestTransactionEditor $new = $xaction->getNewValue(); switch ($xaction->getTransactionType()) { - case ManiphestTransaction::TYPE_PROJECTS: case ManiphestTransaction::TYPE_CCS: sort($old); sort($new); @@ -149,11 +144,6 @@ final class ManiphestTransactionEditor return $object->setOwnerPHID($phid); case ManiphestTransaction::TYPE_CCS: return $object->setCCPHIDs($xaction->getNewValue()); - case ManiphestTransaction::TYPE_PROJECTS: - ManiphestTaskProject::updateTaskProjects( - $object, - $xaction->getNewValue()); - return $object; case ManiphestTransaction::TYPE_SUBPRIORITY: $data = $xaction->getNewValue(); $new_sub = $this->getNextSubpriority( @@ -425,15 +415,14 @@ final class ManiphestTransactionEditor $project_phids = $adapter->getProjectPHIDs(); if ($project_phids) { - $existing_projects = $object->getProjectPHIDs(); - $new_projects = array_unique( - array_merge( - $project_phids, - $existing_projects)); - + $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xactions[] = id(new ManiphestTransaction()) - ->setTransactionType(ManiphestTransaction::TYPE_PROJECTS) - ->setNewValue($new_projects); + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $project_type) + ->setNewValue( + array( + '+' => array_fuse($project_phids), + )); } return $xactions; @@ -450,8 +439,6 @@ final class ManiphestTransactionEditor ManiphestCapabilityEditPriority::CAPABILITY, ManiphestTransaction::TYPE_STATUS => ManiphestCapabilityEditStatus::CAPABILITY, - ManiphestTransaction::TYPE_PROJECTS => - ManiphestCapabilityEditProjects::CAPABILITY, ManiphestTransaction::TYPE_OWNER => ManiphestCapabilityEditAssign::CAPABILITY, PhabricatorTransactions::TYPE_EDIT_POLICY => @@ -460,8 +447,19 @@ final class ManiphestTransactionEditor ManiphestCapabilityEditPolicies::CAPABILITY, ); + $transaction_type = $xaction->getTransactionType(); - $app_capability = idx($app_capability_map, $transaction_type); + + $app_capability = null; + if ($transaction_type == PhabricatorTransactions::TYPE_EDGE) { + switch ($xaction->getMetadataValue('edge:type')) { + case PhabricatorProjectObjectHasProjectEdgeType::EDGECONST: + $app_capability = ManiphestCapabilityEditProjects::CAPABILITY; + break; + } + } else { + $app_capability = idx($app_capability_map, $transaction_type); + } if ($app_capability) { $app = id(new PhabricatorApplicationQuery()) diff --git a/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php b/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php index e4211dc9c9..a3d27ca1c3 100644 --- a/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php +++ b/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php @@ -30,8 +30,6 @@ final class PhabricatorManiphestTaskTestDataGenerator $this->generateTaskPriority(); $changes[ManiphestTransaction::TYPE_CCS] = $this->getCCPHIDs(); - $changes[ManiphestTransaction::TYPE_PROJECTS] = - $this->getProjectPHIDs(); $transactions = array(); foreach ($changes as $type => $value) { $transaction = clone $template; diff --git a/src/applications/maniphest/storage/ManiphestTaskProject.php b/src/applications/maniphest/storage/ManiphestTaskProject.php deleted file mode 100644 index d5d002466b..0000000000 --- a/src/applications/maniphest/storage/ManiphestTaskProject.php +++ /dev/null @@ -1,49 +0,0 @@ - Project table, which denormalizes the - * relationship between tasks and projects into a link table so it can be - * efficiently queried. This table is not authoritative; the projectPHIDs field - * of ManiphestTask is. The rows in this table are regenerated when transactions - * are applied to tasks which affected their associated projects. - */ -final class ManiphestTaskProject extends ManiphestDAO { - - protected $taskPHID; - protected $projectPHID; - - public function getConfiguration() { - return array( - self::CONFIG_IDS => self::IDS_MANUAL, - self::CONFIG_TIMESTAMPS => false, - ); - } - - public static function updateTaskProjects( - ManiphestTask $task, - array $new_phids) { - - $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; - - $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( - $task->getPHID(), - $edge_type); - - $add_phids = array_diff($new_phids, $old_phids); - $rem_phids = array_diff($old_phids, $new_phids); - - if (!$add_phids && !$rem_phids) { - return; - } - - $editor = new PhabricatorEdgeEditor(); - foreach ($add_phids as $phid) { - $editor->addEdge($task->getPHID(), $edge_type, $phid); - } - foreach ($rem_phids as $phid) { - $editor->remEdge($task->getPHID(), $edge_type, $phid); - } - $editor->save(); - } - -} diff --git a/src/applications/maniphest/storage/ManiphestTransaction.php b/src/applications/maniphest/storage/ManiphestTransaction.php index 685d56f393..d3185d661c 100644 --- a/src/applications/maniphest/storage/ManiphestTransaction.php +++ b/src/applications/maniphest/storage/ManiphestTransaction.php @@ -788,8 +788,15 @@ final class ManiphestTransaction case self::TYPE_CCS: $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_CC; break; - case self::TYPE_PROJECTS: - $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PROJECTS; + case PhabricatorTransactions::TYPE_EDGE: + switch ($this->getMetadataValue('edge:type')) { + case PhabricatorProjectObjectHasProjectEdgeType::EDGECONST: + $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PROJECTS; + break; + default: + $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_OTHER; + break; + } break; case self::TYPE_PRIORITY: $tags[] = MetaMTANotificationType::TYPE_MANIPHEST_PRIORITY; From 086fe952e65e2439d3be8c5b881cf0be44fda29a Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:43:55 -0700 Subject: [PATCH 15/44] Add translated strings for new edge types Summary: Ref T5245. Earlier changes in this stack introduced new edge strings, provide English translations. Test Plan: This is hard to test exhastively, but I poked around the UI and saw some of these rendering correctly. If I messed anything up it's trivial to fix when someone spots it. Reviewers: joshuaspence, chad Reviewed By: joshuaspence, chad Subscribers: epriestley Maniphest Tasks: T5245 Differential Revision: https://secure.phabricator.com/D9920 --- .../PhabricatorBaseEnglishTranslation.php | 138 +++++++++++++++++- 1 file changed, 137 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php index 338eadc068..d0888d496e 100644 --- a/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php +++ b/src/infrastructure/internationalization/translation/PhabricatorBaseEnglishTranslation.php @@ -936,7 +936,143 @@ abstract class PhabricatorBaseEnglishTranslation '%s updated JIRA issue(s): added %d %s; removed %d %s.' => '%s updated JIRA issues: added %3$s; removed %5$s.', + '%s added %s task(s): %s.' => array( + array( + '%s added a task: %3$s.', + '%s added tasks: %3$s.', + ), + ), + + '%s removed %s task(s): %s.' => array( + array( + '%s removed a task: %3$s.', + '%s removed tasks: %3$s.', + ), + ), + + '%s edited %s task(s), added %s: %s; removed %s: %s.' => + '%s edited tasks, added %4$s; removed %6$s.', + + '%s added %s task(s) to %s: %s.' => array( + array( + '%s added a task to %3$s: %4$s.', + '%s added tasks to %3$s: %4$s.', + ), + ), + + '%s removed %s task(s) from %s: %s.' => array( + array( + '%s removed a task from %3$s: %4$s.', + '%s removed tasks from %3$s: %4$s.', + ), + ), + + '%s edited %s task(s) for %s, added %s: %s; removed %s: %s.' => + '%s edited tasks for %3$s, added: %5$s; removed %7$s.', + + '%s added %s commit(s): %s.' => array( + array( + '%s added a commit: %3$s.', + '%s added commits: %3$s.', + ), + ), + + '%s removed %s commit(s): %s.' => array( + array( + '%s removed a commit: %3$s.', + '%s removed commits: %3$s.', + ), + ), + + '%s edited %s commit(s), added %s: %s; removed %s: %s.' => + '%s edited commits, added %4$s; removed %6$s.', + + '%s added %s commit(s) to %s: %s.' => array( + array( + '%s added a commit to %3$s: %4$s.', + '%s added commits to %3$s: %4$s.', + ), + ), + + '%s removed %s commit(s) from %s: %s.' => array( + array( + '%s removed a commit from %3$s: %4$s.', + '%s removed commits from %3$s: %4$s.', + ), + ), + + '%s edited %s commit(s) for %s, added %s: %s; removed %s: %s.' => + '%s edited commits for %3$s, added: %5$s; removed %7$s.', + + '%s added %s revision(s): %s.' => array( + array( + '%s added a revision: %3$s.', + '%s added revisionss: %3$s.', + ), + ), + + '%s removed %s revision(s): %s.' => array( + array( + '%s removed a revision: %3$s.', + '%s removed revisions: %3$s.', + ), + ), + + '%s edited %s revision(s), added %s: %s; removed %s: %s.' => + '%s edited revisions, added %4$s; removed %6$s.', + + '%s added %s revision(s) to %s: %s.' => array( + array( + '%s added a revision to %3$s: %4$s.', + '%s added revisions to %3$s: %4$s.', + ), + ), + + '%s removed %s revision(s) from %s: %s.' => array( + array( + '%s removed a revision from %3$s: %4$s.', + '%s removed revisions from %3$s: %4$s.', + ), + ), + + '%s edited %s revision(s) for %s, added %s: %s; removed %s: %s.' => + '%s edited revisions for %3$s, added: %5$s; removed %7$s.', + + '%s added %s project(s): %s.' => array( + array( + '%s added a project: %3$s.', + '%s added projects: %3$s.', + ), + ), + + '%s removed %s project(s): %s.' => array( + array( + '%s removed a project: %3$s.', + '%s removed projects: %3$s.', + ), + ), + + '%s edited %s project(s), added %s: %s; removed %s: %s.' => + '%s edited projects, added %4$s; removed %6$s.', + + '%s added %s project(s) to %s: %s.' => array( + array( + '%s added a project to %3$s: %4$s.', + '%s added projects to %3$s: %4$s.', + ), + ), + + '%s removed %s project(s) from %s: %s.' => array( + array( + '%s removed a project from %3$s: %4$s.', + '%s removed projects from %3$s: %4$s.', + ), + ), + + '%s edited %s project(s) for %s, added %s: %s; removed %s: %s.' => + '%s edited projects for %3$s, added: %5$s; removed %7$s.', + ); } - } +} From dcc69977932be59194f8358aafe8fe4c5571c132 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:44:18 -0700 Subject: [PATCH 16/44] Modernize "users" typeahead datasource Summary: Ref T4420. Modernize users. Test Plan: - Edited "Commit Authors" on Audit search. - Edited "Created By" on calendar search. - Edited "invited" on calendar search. - Edited "To" on "New conpherence message". - Edited user on "Add user to conpherence thread". - Edited "Authors" on countdown search. - Edited "Author" on differential search. - Edited "Responsible users" on differential search. - Edited "Owner" on Diffusion lint search. - Edited "include users" on Feed search. - Edited "Authors" on file search. - Edited "Authors" on Herald rule search. - Edited a couple of user-selecting Herald fields on rules. - Edited "user" on legalpad signature exemption. - Edited "creator" on legalpad search. - Edited "contributors" on legalpad search. - Edited "signers" on legalpad signature search. - Edited "Authors" on macro search. - Edited "Reassign/claim" on task detail. - Edited "assigned to" on task edit. - Edited "assigned to", "users projects", "authors" on task search. - Edited "creators" on oauthserver. - Edited "authors" on paste search. - Edited "actors" and "users" on activity log search. - Edited "authors" on pholio search. - Edited "users" on phrequent search. - Edited "authors", "answered by" on Ponder search. - Edited "add members" on project membership editor. - Edited "members" on project search. - Edited "pushers" on releeph product edit. - Edited "requestors" on releeph request search. - Edited "pushers" on diffusion push log. - Edited "authors", "owners", "subscribers" on global search. - Edited "authors" on slowvote search. - Edited users in custom policy. - Grepped for "common/authors", no hits. - Grepped for "common/users", no (relevant) hits. - Grepped for "common/accounts", no (relevant) hits. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9885 --- resources/celerity/map.php | 26 ++-- src/__phutil_library_map__.php | 2 + .../query/PhabricatorCommitSearchEngine.php | 2 +- .../PhabricatorCalendarEventSearchEngine.php | 4 +- .../controller/ConpherenceNewController.php | 2 +- .../ConpherenceUpdateController.php | 2 +- .../PhabricatorCountdownSearchEngine.php | 2 +- .../DifferentialRevisionSearchEngine.php | 4 +- .../controller/DiffusionLintController.php | 2 +- .../query/PhabricatorFeedSearchEngine.php | 2 +- .../query/PhabricatorFileSearchEngine.php | 2 +- .../controller/HeraldRuleController.php | 2 +- .../herald/query/HeraldRuleSearchEngine.php | 2 +- ...LegalpadDocumentSignatureAddController.php | 2 +- .../query/LegalpadDocumentSearchEngine.php | 4 +- .../LegalpadDocumentSignatureSearchEngine.php | 2 +- .../query/PhabricatorMacroSearchEngine.php | 2 +- .../ManiphestTaskDetailController.php | 5 +- .../ManiphestTaskEditController.php | 2 +- .../query/ManiphestTaskSearchEngine.php | 6 +- ...abricatorOAuthServerClientSearchEngine.php | 2 +- .../query/PhabricatorPasteSearchEngine.php | 2 +- .../PhabricatorPeopleLogSearchEngine.php | 4 +- .../typeahead/PhabricatorPeopleDatasource.php | 121 ++++++++++++++++++ .../pholio/query/PholioMockSearchEngine.php | 2 +- .../phrequent/query/PhrequentSearchEngine.php | 2 +- .../rule/PhabricatorPolicyRuleUsers.php | 6 +- .../query/PonderQuestionSearchEngine.php | 4 +- ...habricatorProjectMembersEditController.php | 2 +- .../query/PhabricatorProjectSearchEngine.php | 2 +- .../product/ReleephProductEditController.php | 2 +- .../query/ReleephRequestSearchEngine.php | 2 +- ...abricatorRepositoryPushLogSearchEngine.php | 2 +- ...abricatorSearchApplicationSearchEngine.php | 4 +- .../query/PhabricatorSlowvoteSearchEngine.php | 2 +- ...torTypeaheadCommonDatasourceController.php | 5 - .../PhabricatorStandardCustomFieldUsers.php | 4 +- .../policy/behavior-policy-rule-editor.js | 4 +- 38 files changed, 185 insertions(+), 64 deletions(-) create mode 100644 src/applications/people/typeahead/PhabricatorPeopleDatasource.php diff --git a/resources/celerity/map.php b/resources/celerity/map.php index f46043717b..7d6d649570 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -414,7 +414,7 @@ return array( 'rsrc/js/application/phortune/behavior-test-payment-form.js' => 'ab8d2723', 'rsrc/js/application/phortune/phortune-credit-card-form.js' => '2290aeef', 'rsrc/js/application/policy/behavior-policy-control.js' => 'f3fef818', - 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '92918fcb', + 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '0ea85aa3', 'rsrc/js/application/ponder/behavior-votebox.js' => '4e9b766b', 'rsrc/js/application/projects/behavior-boards-dropdown.js' => '0ec56e1d', 'rsrc/js/application/projects/behavior-project-boards.js' => 'c6b95cbd', @@ -641,7 +641,7 @@ return array( 'javelin-behavior-phui-object-box-tabs' => 'a3e2244e', 'javelin-behavior-phui-timeline-dropdown-menu' => '4d94d9c3', 'javelin-behavior-policy-control' => 'f3fef818', - 'javelin-behavior-policy-rule-editor' => '92918fcb', + 'javelin-behavior-policy-rule-editor' => '0ea85aa3', 'javelin-behavior-ponder-votebox' => '4e9b766b', 'javelin-behavior-project-boards' => 'c6b95cbd', 'javelin-behavior-project-create' => '065227cc', @@ -899,6 +899,17 @@ return array( 3 => 'javelin-util', 4 => 'phabricator-notification-css', ), + '0ea85aa3' => array( + 0 => 'javelin-behavior', + 1 => 'multirow-row-manager', + 2 => 'javelin-dom', + 3 => 'javelin-util', + 4 => 'phabricator-prefab', + 5 => 'javelin-tokenizer', + 6 => 'javelin-typeahead', + 7 => 'javelin-typeahead-ondemand-source', + 8 => 'javelin-json', + ), '0ec56e1d' => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', @@ -1450,17 +1461,6 @@ return array( 1 => 'javelin-uri', 2 => 'phabricator-notification', ), - '92918fcb' => array( - 0 => 'javelin-behavior', - 1 => 'multirow-row-manager', - 2 => 'javelin-dom', - 3 => 'javelin-util', - 4 => 'phabricator-prefab', - 5 => 'javelin-tokenizer', - 6 => 'javelin-typeahead', - 7 => 'javelin-typeahead-preloaded-source', - 8 => 'javelin-json', - ), '92eb531d' => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index fec80ea1af..e1bd18076b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1910,6 +1910,7 @@ phutil_register_library_map(array( 'PhabricatorPeopleCalendarController' => 'applications/people/controller/PhabricatorPeopleCalendarController.php', 'PhabricatorPeopleController' => 'applications/people/controller/PhabricatorPeopleController.php', 'PhabricatorPeopleCreateController' => 'applications/people/controller/PhabricatorPeopleCreateController.php', + 'PhabricatorPeopleDatasource' => 'applications/people/typeahead/PhabricatorPeopleDatasource.php', 'PhabricatorPeopleDeleteController' => 'applications/people/controller/PhabricatorPeopleDeleteController.php', 'PhabricatorPeopleDisableController' => 'applications/people/controller/PhabricatorPeopleDisableController.php', 'PhabricatorPeopleEmpowerController' => 'applications/people/controller/PhabricatorPeopleEmpowerController.php', @@ -4711,6 +4712,7 @@ phutil_register_library_map(array( 'PhabricatorPeopleCalendarController' => 'PhabricatorPeopleController', 'PhabricatorPeopleController' => 'PhabricatorController', 'PhabricatorPeopleCreateController' => 'PhabricatorPeopleController', + 'PhabricatorPeopleDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorPeopleDeleteController' => 'PhabricatorPeopleController', 'PhabricatorPeopleDisableController' => 'PhabricatorPeopleController', 'PhabricatorPeopleEmpowerController' => 'PhabricatorPeopleController', diff --git a/src/applications/audit/query/PhabricatorCommitSearchEngine.php b/src/applications/audit/query/PhabricatorCommitSearchEngine.php index 0a76163264..c448d458f2 100644 --- a/src/applications/audit/query/PhabricatorCommitSearchEngine.php +++ b/src/applications/audit/query/PhabricatorCommitSearchEngine.php @@ -91,7 +91,7 @@ final class PhabricatorCommitSearchEngine ->setValue(array_select_keys($handles, $auditor_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Commit Authors')) ->setValue(array_select_keys($handles, $commit_author_phids))) diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php index c2f5674af5..ccb340653e 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -106,13 +106,13 @@ final class PhabricatorCalendarEventSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('creators') ->setLabel(pht('Created By')) ->setValue($creator_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('invited') ->setLabel(pht('Invited')) ->setValue($invited_handles)) diff --git a/src/applications/conpherence/controller/ConpherenceNewController.php b/src/applications/conpherence/controller/ConpherenceNewController.php index f224de2a13..dad9a95608 100644 --- a/src/applications/conpherence/controller/ConpherenceNewController.php +++ b/src/applications/conpherence/controller/ConpherenceNewController.php @@ -82,7 +82,7 @@ final class ConpherenceNewController extends ConpherenceController { ->setName('participants') ->setValue($participant_handles) ->setUser($user) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setLabel(pht('To')) ->setError($e_participants)) ->appendChild( diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index 137d9f13ac..847dc26790 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -206,7 +206,7 @@ final class ConpherenceUpdateController id(new AphrontFormTokenizerControl()) ->setName('add_person') ->setUser($user) - ->setDatasource('/typeahead/common/users/')); + ->setDatasource(new PhabricatorPeopleDatasource())); require_celerity_resource('conpherence-update-css'); return id(new AphrontDialogView()) diff --git a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php index d0fc715683..b6e255134c 100644 --- a/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php +++ b/src/applications/countdown/query/PhabricatorCountdownSearchEngine.php @@ -51,7 +51,7 @@ final class PhabricatorCountdownSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index 872bab85e0..7a26ee13a9 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -143,13 +143,13 @@ final class DifferentialRevisionSearchEngine id(new AphrontFormTokenizerControl()) ->setLabel(pht('Responsible Users')) ->setName('responsibles') - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue(array_select_keys($handles, $responsible_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) ->setLabel(pht('Authors')) ->setName('authors') - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue(array_select_keys($handles, $author_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/diffusion/controller/DiffusionLintController.php b/src/applications/diffusion/controller/DiffusionLintController.php index b6ce4a423d..fa8693aa62 100644 --- a/src/applications/diffusion/controller/DiffusionLintController.php +++ b/src/applications/diffusion/controller/DiffusionLintController.php @@ -112,7 +112,7 @@ final class DiffusionLintController extends DiffusionController { ->setMethod('GET') ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setLimit(1) ->setName('owner') ->setLabel(pht('Owner')) diff --git a/src/applications/feed/query/PhabricatorFeedSearchEngine.php b/src/applications/feed/query/PhabricatorFeedSearchEngine.php index f9c996c5a6..268406a335 100644 --- a/src/applications/feed/query/PhabricatorFeedSearchEngine.php +++ b/src/applications/feed/query/PhabricatorFeedSearchEngine.php @@ -78,7 +78,7 @@ final class PhabricatorFeedSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('users') ->setLabel(pht('Include Users')) ->setValue($user_handles)) diff --git a/src/applications/files/query/PhabricatorFileSearchEngine.php b/src/applications/files/query/PhabricatorFileSearchEngine.php index afde191e62..d91110f8b9 100644 --- a/src/applications/files/query/PhabricatorFileSearchEngine.php +++ b/src/applications/files/query/PhabricatorFileSearchEngine.php @@ -61,7 +61,7 @@ final class PhabricatorFileSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index 6bf1cb7c3f..b660618a0e 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -596,12 +596,12 @@ final class HeraldRuleController extends HeraldController { 'arcanistprojects' => new DiffusionArcanistProjectDatasource(), 'package' => new PhabricatorOwnersPackageDatasource(), 'project' => new PhabricatorProjectDatasource(), + 'user' => new PhabricatorPeopleDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); $sources += array( 'email' => '/typeahead/common/mailable/', - 'user' => '/typeahead/common/accounts/', 'userorproject' => '/typeahead/common/accountsorprojects/', ); diff --git a/src/applications/herald/query/HeraldRuleSearchEngine.php b/src/applications/herald/query/HeraldRuleSearchEngine.php index 4b009a113f..90fc510b62 100644 --- a/src/applications/herald/query/HeraldRuleSearchEngine.php +++ b/src/applications/herald/query/HeraldRuleSearchEngine.php @@ -71,7 +71,7 @@ final class HeraldRuleSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/legalpad/controller/LegalpadDocumentSignatureAddController.php b/src/applications/legalpad/controller/LegalpadDocumentSignatureAddController.php index e85e7a70c7..47ad308508 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentSignatureAddController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentSignatureAddController.php @@ -130,7 +130,7 @@ final class LegalpadDocumentSignatureAddController extends LegalpadController { ->setLabel(pht('Exempt User')) ->setName('users') ->setLimit(1) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($user_handles) ->setError($e_user)); } else { diff --git a/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php b/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php index 9480273c7b..d80386b815 100644 --- a/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php +++ b/src/applications/legalpad/query/LegalpadDocumentSearchEngine.php @@ -95,13 +95,13 @@ final class LegalpadDocumentSearchEngine ->setDisabled(!$this->requireViewer()->getPHID())) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('creators') ->setLabel(pht('Creators')) ->setValue(array_select_keys($handles, $creator_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('contributors') ->setLabel(pht('Contributors')) ->setValue(array_select_keys($handles, $contributor_phids))); diff --git a/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php b/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php index 2883c6bbef..da1d792998 100644 --- a/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php +++ b/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php @@ -99,7 +99,7 @@ final class LegalpadDocumentSignatureSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('signers') ->setLabel(pht('Signers')) ->setValue(array_select_keys($handles, $signer_phids))) diff --git a/src/applications/macro/query/PhabricatorMacroSearchEngine.php b/src/applications/macro/query/PhabricatorMacroSearchEngine.php index c6af71ede2..9abf99d3aa 100644 --- a/src/applications/macro/query/PhabricatorMacroSearchEngine.php +++ b/src/applications/macro/query/PhabricatorMacroSearchEngine.php @@ -93,7 +93,7 @@ final class PhabricatorMacroSearchEngine ->setValue($status)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index 6465919ed9..de6e767dfe 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -283,6 +283,7 @@ final class ManiphestTaskDetailController extends ManiphestController { ); $projects_source = new PhabricatorProjectDatasource(); + $users_source = new PhabricatorPeopleDatasource(); $tokenizer_map = array( ManiphestTransaction::TYPE_PROJECTS => array( @@ -292,10 +293,10 @@ final class ManiphestTaskDetailController extends ManiphestController { ), ManiphestTransaction::TYPE_OWNER => array( 'id' => 'assign-tokenizer', - 'src' => '/typeahead/common/users/', + 'src' => $users_source->getDatasourceURI(), 'value' => $default_claim, 'limit' => 1, - 'placeholder' => pht('Type a user name...'), + 'placeholder' => $users_source->getPlaceholderText(), ), ManiphestTransaction::TYPE_CCS => array( 'id' => 'cc-tokenizer', diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index de6b272068..e08b675e52 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -602,7 +602,7 @@ final class ManiphestTaskEditController extends ManiphestController { ->setName('assigned_to') ->setValue($assigned_value) ->setUser($user) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setLimit(1)); } diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index 9a948ffc65..0acaba4374 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -309,7 +309,7 @@ final class ManiphestTaskSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('assigned') ->setLabel(pht('Assigned To')) ->setValue($assigned_handles)) @@ -353,13 +353,13 @@ final class ManiphestTaskSearchEngine ->setValue($exclude_project_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('userProjects') ->setLabel(pht('In Users\' Projects')) ->setValue($user_project_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php b/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php index 25323f5129..ac777c3f59 100644 --- a/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php +++ b/src/applications/oauthserver/query/PhabricatorOAuthServerClientSearchEngine.php @@ -45,7 +45,7 @@ final class PhabricatorOAuthServerClientSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('creators') ->setLabel(pht('Creators')) ->setValue($creator_handles)); diff --git a/src/applications/paste/query/PhabricatorPasteSearchEngine.php b/src/applications/paste/query/PhabricatorPasteSearchEngine.php index b589b25907..79cf87b9f6 100644 --- a/src/applications/paste/query/PhabricatorPasteSearchEngine.php +++ b/src/applications/paste/query/PhabricatorPasteSearchEngine.php @@ -67,7 +67,7 @@ final class PhabricatorPasteSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php b/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php index 8af0e65838..772ae6005e 100644 --- a/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php +++ b/src/applications/people/query/PhabricatorPeopleLogSearchEngine.php @@ -124,13 +124,13 @@ final class PhabricatorPeopleLogSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('actors') ->setLabel(pht('Actors')) ->setValue($actor_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('users') ->setLabel(pht('Users')) ->setValue($user_handles)) diff --git a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php new file mode 100644 index 0000000000..26e7cbe9f2 --- /dev/null +++ b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php @@ -0,0 +1,121 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $users = array(); + if (strlen($raw_query)) { + // This is an arbitrary limit which is just larger than any limit we + // actually use in the application. + + // TODO: The datasource should pass this in the query. + $limit = 15; + + $user_table = new PhabricatorUser(); + $conn_r = $user_table->establishConnection('r'); + $ids = queryfx_all( + $conn_r, + 'SELECT id FROM %T WHERE username LIKE %> + ORDER BY username ASC LIMIT %d', + $user_table->getTableName(), + $raw_query, + $limit); + $ids = ipull($ids, 'id'); + + if (count($ids) < $limit) { + // If we didn't find enough username hits, look for real name hits. + // We need to pull the entire pagesize so that we end up with the + // right number of items if this query returns many duplicate IDs + // that we've already selected. + + $realname_ids = queryfx_all( + $conn_r, + 'SELECT DISTINCT userID FROM %T WHERE token LIKE %> + ORDER BY token ASC LIMIT %d', + PhabricatorUser::NAMETOKEN_TABLE, + $raw_query, + $limit); + $realname_ids = ipull($realname_ids, 'userID'); + $ids = array_merge($ids, $realname_ids); + + $ids = array_unique($ids); + $ids = array_slice($ids, 0, $limit); + } + + // Always add the logged-in user because some tokenizers autosort them + // first. They'll be filtered out on the client side if they don't + // match the query. + if ($viewer->getID()) { + $ids[] = $viewer->getID(); + } + + if ($ids) { + $users = id(new PhabricatorPeopleQuery()) + ->setViewer($viewer) + ->withIDs($ids) + ->execute(); + } + } + + // TODO: Restore this when mainsearch moves here. + /* + + if ($need_rich_data) { + $phids = mpull($users, 'getPHID'); + $handles = $this->loadViewerHandles($phids); + } + + */ + + foreach ($users as $user) { + $closed = null; + if ($user->getIsDisabled()) { + $closed = pht('Disabled'); + } else if ($user->getIsSystemAgent()) { + $closed = pht('Bot/Script'); + } + + $result = id(new PhabricatorTypeaheadResult()) + ->setName($user->getFullName()) + ->setURI('/p/'.$user->getUsername()) + ->setPHID($user->getPHID()) + ->setPriorityString($user->getUsername()) + ->setIcon('fa-user bluegrey') + ->setPriorityType('user') + ->setClosed($closed); + + // TODO: Restore this too. + /* + + if ($need_rich_data) { + $display_type = 'User'; + if ($user->getIsAdmin()) { + $display_type = 'Administrator'; + } + $result->setDisplayType($display_type); + $result->setImageURI($handles[$user->getPHID()]->getImageURI()); + } + + */ + + $results[] = $result; + } + + return $results; + } + +} diff --git a/src/applications/pholio/query/PholioMockSearchEngine.php b/src/applications/pholio/query/PholioMockSearchEngine.php index 231d020ca5..3b214e7d63 100644 --- a/src/applications/pholio/query/PholioMockSearchEngine.php +++ b/src/applications/pholio/query/PholioMockSearchEngine.php @@ -55,7 +55,7 @@ final class PholioMockSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/phrequent/query/PhrequentSearchEngine.php b/src/applications/phrequent/query/PhrequentSearchEngine.php index 1a90463bd2..6c3a4e1566 100644 --- a/src/applications/phrequent/query/PhrequentSearchEngine.php +++ b/src/applications/phrequent/query/PhrequentSearchEngine.php @@ -69,7 +69,7 @@ final class PhrequentSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('users') ->setLabel(pht('Users')) ->setValue($handles)) diff --git a/src/applications/policy/rule/PhabricatorPolicyRuleUsers.php b/src/applications/policy/rule/PhabricatorPolicyRuleUsers.php index d405fb115a..16d038e5d2 100644 --- a/src/applications/policy/rule/PhabricatorPolicyRuleUsers.php +++ b/src/applications/policy/rule/PhabricatorPolicyRuleUsers.php @@ -21,10 +21,12 @@ final class PhabricatorPolicyRuleUsers } public function getValueControlTemplate() { + $users_datasource = new PhabricatorPeopleDatasource(); + return array( 'markup' => new AphrontTokenizerTemplateView(), - 'uri' => '/typeahead/common/accounts/', - 'placeholder' => pht('Type a user name...'), + 'uri' => $users_datasource->getDatasourceURI(), + 'placeholder' => $users_datasource->getPlaceholderText(), ); } diff --git a/src/applications/ponder/query/PonderQuestionSearchEngine.php b/src/applications/ponder/query/PonderQuestionSearchEngine.php index 9592341530..8be8ec1b9c 100644 --- a/src/applications/ponder/query/PonderQuestionSearchEngine.php +++ b/src/applications/ponder/query/PonderQuestionSearchEngine.php @@ -73,13 +73,13 @@ final class PonderQuestionSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue(array_select_keys($handles, $author_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('answerers') ->setLabel(pht('Answered By')) ->setValue(array_select_keys($handles, $answerer_phids))) diff --git a/src/applications/project/controller/PhabricatorProjectMembersEditController.php b/src/applications/project/controller/PhabricatorProjectMembersEditController.php index 24663967bd..7fc8bb4019 100644 --- a/src/applications/project/controller/PhabricatorProjectMembersEditController.php +++ b/src/applications/project/controller/PhabricatorProjectMembersEditController.php @@ -83,7 +83,7 @@ final class PhabricatorProjectMembersEditController id(new AphrontFormTokenizerControl()) ->setName('phids') ->setLabel(pht('Add Members')) - ->setDatasource('/typeahead/common/accounts/')) + ->setDatasource(new PhabricatorPeopleDatasource())) ->appendChild( id(new AphrontFormSubmitControl()) ->addCancelButton('/project/view/'.$project->getID().'/') diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index d842dab983..0122e17d0b 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -63,7 +63,7 @@ final class PhabricatorProjectSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('members') ->setLabel(pht('Members')) ->setValue($member_handles)) diff --git a/src/applications/releeph/controller/product/ReleephProductEditController.php b/src/applications/releeph/controller/product/ReleephProductEditController.php index 855ef06530..bd4a108ca1 100644 --- a/src/applications/releeph/controller/product/ReleephProductEditController.php +++ b/src/applications/releeph/controller/product/ReleephProductEditController.php @@ -194,7 +194,7 @@ final class ReleephProductEditController extends ReleephProductController { id(new AphrontFormTokenizerControl()) ->setLabel(pht('Pushers')) ->setName('pushers') - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($pusher_handles)) ->appendChild($branch_template_input) ->appendChild($branch_template_preview) diff --git a/src/applications/releeph/query/ReleephRequestSearchEngine.php b/src/applications/releeph/query/ReleephRequestSearchEngine.php index cbae3ab65a..072bb334ef 100644 --- a/src/applications/releeph/query/ReleephRequestSearchEngine.php +++ b/src/applications/releeph/query/ReleephRequestSearchEngine.php @@ -84,7 +84,7 @@ final class ReleephRequestSearchEngine ->setOptions($this->getSeverityOptions())) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('requestors') ->setLabel(pht('Requestors')) ->setValue($requestor_handles)); diff --git a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php index 757ef03f27..cb4f1fdd8e 100644 --- a/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php +++ b/src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php @@ -80,7 +80,7 @@ final class PhabricatorRepositoryPushLogSearchEngine ->setValue($repository_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('pushers') ->setLabel(pht('Pushers')) ->setValue($pusher_handles)); diff --git a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php index 249089f380..76c7b4013f 100644 --- a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php +++ b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php @@ -136,7 +136,7 @@ final class PhabricatorSearchApplicationSearchEngine id(new AphrontFormTokenizerControl()) ->setName('authorPHIDs') ->setLabel('Authors') - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($author_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) @@ -155,7 +155,7 @@ final class PhabricatorSearchApplicationSearchEngine id(new AphrontFormTokenizerControl()) ->setName('subscriberPHIDs') ->setLabel('Subscribers') - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($subscriber_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php index d822e740be..e0e8baf0ba 100644 --- a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php +++ b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php @@ -55,7 +55,7 @@ final class PhabricatorSlowvoteSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/users/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setName('authors') ->setLabel(pht('Authors')) ->setValue($author_handles)) diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index b424ea00a8..7a52bbb3a6 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -48,11 +48,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_projs = true; $need_noproject = true; break; - case 'users': - case 'accounts': - case 'authors': - $need_users = true; - break; case 'mailable': case 'allmailable': $need_users = true; diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php index 2ff1d4589c..440ac7dab7 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php @@ -18,7 +18,7 @@ final class PhabricatorStandardCustomFieldUsers $control = id(new AphrontFormTokenizerControl()) ->setLabel($this->getFieldName()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setCaption($this->getCaption()) ->setValue($control_value); @@ -39,7 +39,7 @@ final class PhabricatorStandardCustomFieldUsers $control = id(new AphrontFormTokenizerControl()) ->setLabel($this->getFieldName()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/accounts/') + ->setDatasource(new PhabricatorPeopleDatasource()) ->setValue($handles); $form->appendChild($control); diff --git a/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js b/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js index 94986df2f3..af3d382a99 100644 --- a/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js +++ b/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js @@ -7,7 +7,7 @@ * phabricator-prefab * javelin-tokenizer * javelin-typeahead - * javelin-typeahead-preloaded-source + * javelin-typeahead-ondemand-source * javelin-json */ JX.behavior('policy-rule-editor', function(config) { @@ -124,7 +124,7 @@ JX.behavior('policy-rule-editor', function(config) { node = JX.$H(template.markup).getNode(); node.id = ''; - var datasource = new JX.TypeaheadPreloadedSource(template.uri); + var datasource = new JX.TypeaheadOnDemandSource(template.uri); var typeahead = new JX.Typeahead(node); typeahead.setDatasource(datasource); From 778c970e312e79316f1534f400d7f498e2be4a77 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:44:29 -0700 Subject: [PATCH 17/44] Modernize "mailable" typeahead datasources Summary: Ref T4420. Modernize the mailing list datasource, then build a composite "mailable" datasource. Test Plan: - Edited "subscribers" field in Differential revision edit. - Edited "subscribers" field in Differential search. - Edited "add subscribers" field in differential revision view. - Edited "add ccs" field in Diffusion commit view. - Edited "add emails to CC" in a Herald rule. - Edited "add ccs" in maniphest bulk editor. - Edited "add ccs" in maniphest task detail view. - Edited "CC" on maniphest edit view. - Edited "subscribers" on maniphest task earch view. - Edited "CC" on pholio mock edit. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9886 --- src/__phutil_library_map__.php | 4 +++ .../DifferentialSubscribersField.php | 2 +- .../DifferentialRevisionSearchEngine.php | 2 +- .../view/DifferentialAddCommentView.php | 6 ++-- .../controller/DiffusionCommitController.php | 6 ++-- .../controller/HeraldRuleController.php | 2 +- .../PhabricatorMailingListDatasource.php | 33 +++++++++++++++++++ .../ManiphestBatchEditController.php | 5 +-- .../ManiphestTaskDetailController.php | 5 +-- .../ManiphestTaskEditController.php | 2 +- .../query/ManiphestTaskSearchEngine.php | 2 +- .../PhabricatorMetaMTAMailableDatasource.php | 22 +++++++++++++ .../controller/PholioMockEditController.php | 2 +- ...torTypeaheadCommonDatasourceController.php | 19 ----------- .../control/AphrontFormTokenizerControl.php | 10 ------ 15 files changed, 79 insertions(+), 43 deletions(-) create mode 100644 src/applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php create mode 100644 src/applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e1bd18076b..d4be5274a2 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1768,6 +1768,7 @@ phutil_register_library_map(array( 'PhabricatorMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php', 'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php', 'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php', + 'PhabricatorMailingListDatasource' => 'applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php', 'PhabricatorMailingListPHIDTypeList' => 'applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php', 'PhabricatorMailingListQuery' => 'applications/mailinglists/query/PhabricatorMailingListQuery.php', 'PhabricatorMailingListSearchEngine' => 'applications/mailinglists/query/PhabricatorMailingListSearchEngine.php', @@ -1800,6 +1801,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAMailBody' => 'applications/metamta/view/PhabricatorMetaMTAMailBody.php', 'PhabricatorMetaMTAMailBodyTestCase' => 'applications/metamta/view/__tests__/PhabricatorMetaMTAMailBodyTestCase.php', 'PhabricatorMetaMTAMailTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php', + 'PhabricatorMetaMTAMailableDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php', 'PhabricatorMetaMTAMailgunReceiveController' => 'applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php', 'PhabricatorMetaMTAMailingList' => 'applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php', 'PhabricatorMetaMTAMemberQuery' => 'applications/metamta/query/PhabricatorMetaMTAMemberQuery.php', @@ -4567,6 +4569,7 @@ phutil_register_library_map(array( 'PhabricatorMailManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase', 'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions', + 'PhabricatorMailingListDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorMailingListPHIDTypeList' => 'PhabricatorPHIDType', 'PhabricatorMailingListQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorMailingListSearchEngine' => 'PhabricatorApplicationSearchEngine', @@ -4593,6 +4596,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAMail' => 'PhabricatorMetaMTADAO', 'PhabricatorMetaMTAMailBodyTestCase' => 'PhabricatorTestCase', 'PhabricatorMetaMTAMailTestCase' => 'PhabricatorTestCase', + 'PhabricatorMetaMTAMailableDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorMetaMTAMailgunReceiveController' => 'PhabricatorMetaMTAController', 'PhabricatorMetaMTAMailingList' => array( 0 => 'PhabricatorMetaMTADAO', diff --git a/src/applications/differential/customfield/DifferentialSubscribersField.php b/src/applications/differential/customfield/DifferentialSubscribersField.php index 4d2a9f016a..eba9a62025 100644 --- a/src/applications/differential/customfield/DifferentialSubscribersField.php +++ b/src/applications/differential/customfield/DifferentialSubscribersField.php @@ -44,7 +44,7 @@ final class DifferentialSubscribersField public function renderEditControl(array $handles) { return id(new AphrontFormTokenizerControl()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/mailable/') + ->setDatasource(new PhabricatorMetaMTAMailableDatasource()) ->setValue($handles) ->setError($this->getFieldError()) ->setLabel($this->getFieldName()); diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index 7a26ee13a9..51ef4791ac 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -161,7 +161,7 @@ final class DifferentialRevisionSearchEngine id(new AphrontFormTokenizerControl()) ->setLabel(pht('Subscribers')) ->setName('subscribers') - ->setDatasource('/typeahead/common/allmailable/') + ->setDatasource(new PhabricatorMetaMTAMailableDatasource()) ->setValue(array_select_keys($handles, $subscriber_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/differential/view/DifferentialAddCommentView.php b/src/applications/differential/view/DifferentialAddCommentView.php index 9ccd73971c..48b70d6c99 100644 --- a/src/applications/differential/view/DifferentialAddCommentView.php +++ b/src/applications/differential/view/DifferentialAddCommentView.php @@ -108,6 +108,8 @@ final class DifferentialAddCommentView extends AphrontView { id(new AphrontFormSubmitControl()) ->setValue(pht('Submit'))); + $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + Javelin::initBehavior( 'differential-add-reviewers-and-ccs', array( @@ -126,10 +128,10 @@ final class DifferentialAddCommentView extends AphrontView { ), 'add-ccs-tokenizer' => array( 'actions' => array('add_ccs' => 1), - 'src' => '/typeahead/common/mailable/', + 'src' => $mailable_source->getDatasourceURI(), 'value' => $this->ccs, 'row' => 'add-ccs', - 'placeholder' => pht('Type a user or mailing list...'), + 'placeholder' => $mailable_source->getPlaceholderText(), ), ), 'select' => 'comment-action', diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 6716f0e033..3e672c19f7 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -771,6 +771,8 @@ final class DiffusionCommitController extends DiffusionController { require_celerity_resource('phabricator-transaction-view-css'); + $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + Javelin::initBehavior( 'differential-add-reviewers-and-ccs', array( @@ -783,9 +785,9 @@ final class DiffusionCommitController extends DiffusionController { ), 'add-ccs-tokenizer' => array( 'actions' => array('add_ccs' => 1), - 'src' => '/typeahead/common/mailable/', + 'src' => $mailable_source->getDatasourceURI(), 'row' => 'add-ccs', - 'placeholder' => pht('Type a user or mailing list...'), + 'placeholder' => $mailable_source->getPlaceholderText(), ), ), 'select' => 'audit-action', diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index b660618a0e..b31329a09e 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -597,11 +597,11 @@ final class HeraldRuleController extends HeraldController { 'package' => new PhabricatorOwnersPackageDatasource(), 'project' => new PhabricatorProjectDatasource(), 'user' => new PhabricatorPeopleDatasource(), + 'email' => new PhabricatorMetaMTAMailableDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); $sources += array( - 'email' => '/typeahead/common/mailable/', 'userorproject' => '/typeahead/common/accountsorprojects/', ); diff --git a/src/applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php b/src/applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php new file mode 100644 index 0000000000..48f5b83da7 --- /dev/null +++ b/src/applications/mailinglists/typeahead/PhabricatorMailingListDatasource.php @@ -0,0 +1,33 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $lists = id(new PhabricatorMailingListQuery()) + ->setViewer($viewer) + ->execute(); + foreach ($lists as $list) { + $results[] = id(new PhabricatorTypeaheadResult()) + ->setName($list->getName()) + ->setURI($list->getURI()) + ->setPHID($list->getPHID()); + } + + return $results; + } + +} diff --git a/src/applications/maniphest/controller/ManiphestBatchEditController.php b/src/applications/maniphest/controller/ManiphestBatchEditController.php index 5dfaba42f3..59f361931a 100644 --- a/src/applications/maniphest/controller/ManiphestBatchEditController.php +++ b/src/applications/maniphest/controller/ManiphestBatchEditController.php @@ -62,6 +62,7 @@ final class ManiphestBatchEditController extends ManiphestController { $template = $template->render(); $projects_source = new PhabricatorProjectDatasource(); + $mailable_source = new PhabricatorMetaMTAMailableDatasource(); require_celerity_resource('maniphest-batch-editor'); Javelin::initBehavior( @@ -81,8 +82,8 @@ final class ManiphestBatchEditController extends ManiphestController { 'limit' => 1, ), 'cc' => array( - 'src' => '/typeahead/common/mailable/', - 'placeholder' => pht('Type a user name...'), + 'src' => $mailable_source->getDatasourceURI(), + 'placeholder' => $mailable_source->getPlaceholderText(), ) ), 'input' => 'batch-form-actions', diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php index de6e767dfe..60a8fe5e7c 100644 --- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php @@ -284,6 +284,7 @@ final class ManiphestTaskDetailController extends ManiphestController { $projects_source = new PhabricatorProjectDatasource(); $users_source = new PhabricatorPeopleDatasource(); + $mailable_source = new PhabricatorMetaMTAMailableDatasource(); $tokenizer_map = array( ManiphestTransaction::TYPE_PROJECTS => array( @@ -300,8 +301,8 @@ final class ManiphestTaskDetailController extends ManiphestController { ), ManiphestTransaction::TYPE_CCS => array( 'id' => 'cc-tokenizer', - 'src' => '/typeahead/common/mailable/', - 'placeholder' => pht('Type a user or mailing list...'), + 'src' => $mailable_source->getDatasourceURI(), + 'placeholder' => $mailable_source->getPlaceholderText(), ), ); diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index e08b675e52..b8bf1a7017 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -613,7 +613,7 @@ final class ManiphestTaskEditController extends ManiphestController { ->setName('cc') ->setValue($cc_value) ->setUser($user) - ->setDatasource('/typeahead/common/mailable/')); + ->setDatasource(new PhabricatorMetaMTAMailableDatasource())); if ($can_edit_priority) { $form diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php index 0acaba4374..8079a45380 100644 --- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php +++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php @@ -365,7 +365,7 @@ final class ManiphestTaskSearchEngine ->setValue($author_handles)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/mailable/') + ->setDatasource(new PhabricatorMetaMTAMailableDatasource()) ->setName('subscribers') ->setLabel(pht('Subscribers')) ->setValue($subscriber_handles)) diff --git a/src/applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php b/src/applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php new file mode 100644 index 0000000000..0a6b5ea0b4 --- /dev/null +++ b/src/applications/metamta/typeahead/PhabricatorMetaMTAMailableDatasource.php @@ -0,0 +1,22 @@ +setName('cc') ->setValue($handles) ->setUser($user) - ->setDatasource('/typeahead/common/mailable/')) + ->setDatasource(new PhabricatorMetaMTAMailableDatasource())) ->appendChild( id(new AphrontFormPolicyControl()) ->setUser($user) diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index 7a52bbb3a6..ccf19e23a5 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -24,7 +24,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_users = false; $need_agents = false; $need_applications = false; - $need_lists = false; $need_projs = false; $need_packages = false; $need_upforgrabs = false; @@ -48,12 +47,6 @@ final class PhabricatorTypeaheadCommonDatasourceController $need_projs = true; $need_noproject = true; break; - case 'mailable': - case 'allmailable': - $need_users = true; - $need_lists = true; - $need_projs = true; - break; case 'usersorprojects': case 'accountsorprojects': $need_users = true; @@ -179,18 +172,6 @@ final class PhabricatorTypeaheadCommonDatasourceController } } - if ($need_lists) { - $lists = id(new PhabricatorMailingListQuery()) - ->setViewer($viewer) - ->execute(); - foreach ($lists as $list) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName($list->getName()) - ->setURI($list->getURI()) - ->setPHID($list->getPHID()); - } - } - if ($need_projs) { $projs = id(new PhabricatorProjectQuery()) ->setViewer($viewer) diff --git a/src/view/form/control/AphrontFormTokenizerControl.php b/src/view/form/control/AphrontFormTokenizerControl.php index ff82986a99..31d683db83 100644 --- a/src/view/form/control/AphrontFormTokenizerControl.php +++ b/src/view/form/control/AphrontFormTokenizerControl.php @@ -95,19 +95,9 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $request = $matches[1]; $map = array( - 'users' => pht('Type a user name...'), - 'authors' => pht('Type a user name...'), 'usersorprojects' => pht('Type a user or project name...'), 'searchowner' => pht('Type a user name...'), - 'accounts' => pht('Type a user name...'), - 'mailable' => pht('Type a user, project, or mailing list...'), - 'allmailable' => pht('Type a user, project, or mailing list...'), 'searchproject' => pht('Type a project name...'), - 'projects' => pht('Type a project name...'), - 'repositories' => pht('Type a repository name...'), - 'packages' => pht('Type a package name...'), - 'macros' => pht('Type a macro name...'), - 'arcanistproject' => pht('Type an arc project name...'), 'accountsorprojects' => pht('Type a user or project name...'), 'usersprojectsorpackages' => pht('Type a user, project, or package name...'), From ca5a2641a6d754b2cbbc5b673d32a6016de9775a Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:45:07 -0700 Subject: [PATCH 18/44] Modernize "user or project" typeahead datasources Summary: Ref T4420. These are used for some stuff like "reviewer". Test Plan: - Edited "reviewers" in differential edit. - Edited "reviewers" in differential search. - Edited "reviewers" in Differential "add reviewers..." action on detail page. - Edited a "reviewers" field in a herald rule. - Edited "owner" in owners search. - Edited "primary owner", "owners" on owners edit. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9887 --- src/__phutil_library_map__.php | 2 ++ .../customfield/DifferentialReviewersField.php | 2 +- .../query/DifferentialRevisionSearchEngine.php | 2 +- .../view/DifferentialAddCommentView.php | 5 +++-- .../herald/controller/HeraldRuleController.php | 4 +--- .../PhabricatorOwnersEditController.php | 4 ++-- .../PhabricatorOwnersListController.php | 2 +- .../PhabricatorProjectOrUserDatasource.php | 17 +++++++++++++++++ ...catorTypeaheadCommonDatasourceController.php | 5 ----- .../control/AphrontFormTokenizerControl.php | 2 -- 10 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 src/applications/project/typeahead/PhabricatorProjectOrUserDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d4be5274a2..23efd54c85 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2011,6 +2011,7 @@ phutil_register_library_map(array( 'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php', 'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php', 'PhabricatorProjectObjectHasProjectEdgeType' => 'applications/project/edge/PhabricatorProjectObjectHasProjectEdgeType.php', + 'PhabricatorProjectOrUserDatasource' => 'applications/project/typeahead/PhabricatorProjectOrUserDatasource.php', 'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php', 'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php', 'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php', @@ -4827,6 +4828,7 @@ phutil_register_library_map(array( 'PhabricatorProjectMoveController' => 'PhabricatorProjectController', 'PhabricatorProjectNameCollisionException' => 'Exception', 'PhabricatorProjectObjectHasProjectEdgeType' => 'PhabricatorEdgeType', + 'PhabricatorProjectOrUserDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType', 'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType', 'PhabricatorProjectProfileController' => 'PhabricatorProjectController', diff --git a/src/applications/differential/customfield/DifferentialReviewersField.php b/src/applications/differential/customfield/DifferentialReviewersField.php index 5ff0a2f9f2..d3f24b7d3a 100644 --- a/src/applications/differential/customfield/DifferentialReviewersField.php +++ b/src/applications/differential/customfield/DifferentialReviewersField.php @@ -69,7 +69,7 @@ final class DifferentialReviewersField public function renderEditControl(array $handles) { return id(new AphrontFormTokenizerControl()) ->setName($this->getFieldKey()) - ->setDatasource('/typeahead/common/usersorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setValue($handles) ->setError($this->getFieldError()) ->setLabel($this->getFieldName()); diff --git a/src/applications/differential/query/DifferentialRevisionSearchEngine.php b/src/applications/differential/query/DifferentialRevisionSearchEngine.php index 51ef4791ac..f47665fc85 100644 --- a/src/applications/differential/query/DifferentialRevisionSearchEngine.php +++ b/src/applications/differential/query/DifferentialRevisionSearchEngine.php @@ -155,7 +155,7 @@ final class DifferentialRevisionSearchEngine id(new AphrontFormTokenizerControl()) ->setLabel(pht('Reviewers')) ->setName('reviewers') - ->setDatasource('/typeahead/common/accountsorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setValue(array_select_keys($handles, $reviewer_phids))) ->appendChild( id(new AphrontFormTokenizerControl()) diff --git a/src/applications/differential/view/DifferentialAddCommentView.php b/src/applications/differential/view/DifferentialAddCommentView.php index 48b70d6c99..acb657bd2e 100644 --- a/src/applications/differential/view/DifferentialAddCommentView.php +++ b/src/applications/differential/view/DifferentialAddCommentView.php @@ -109,6 +109,7 @@ final class DifferentialAddCommentView extends AphrontView { ->setValue(pht('Submit'))); $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + $reviewer_source = new PhabricatorProjectOrUserDatasource(); Javelin::initBehavior( 'differential-add-reviewers-and-ccs', @@ -120,11 +121,11 @@ final class DifferentialAddCommentView extends AphrontView { 'add_reviewers' => 1, 'resign' => 1, ), - 'src' => '/typeahead/common/usersorprojects/', + 'src' => $reviewer_source->getDatasourceURI(), 'value' => $this->reviewers, 'row' => 'add-reviewers', 'labels' => $add_reviewers_labels, - 'placeholder' => pht('Type a user or project name...'), + 'placeholder' => $reviewer_source->getPlaceholderText(), ), 'add-ccs-tokenizer' => array( 'actions' => array('add_ccs' => 1), diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index b31329a09e..75a5c297e2 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -598,12 +598,10 @@ final class HeraldRuleController extends HeraldController { 'project' => new PhabricatorProjectDatasource(), 'user' => new PhabricatorPeopleDatasource(), 'email' => new PhabricatorMetaMTAMailableDatasource(), + 'userorproject' => new PhabricatorProjectOrUserDatasource(), ); $sources = mpull($sources, 'getDatasourceURI'); - $sources += array( - 'userorproject' => '/typeahead/common/accountsorprojects/', - ); return array( 'source' => $sources, diff --git a/src/applications/owners/controller/PhabricatorOwnersEditController.php b/src/applications/owners/controller/PhabricatorOwnersEditController.php index f35a9f5edc..aface6a277 100644 --- a/src/applications/owners/controller/PhabricatorOwnersEditController.php +++ b/src/applications/owners/controller/PhabricatorOwnersEditController.php @@ -181,7 +181,7 @@ final class PhabricatorOwnersEditController ->setError($e_name)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/usersorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setLabel(pht('Primary Owner')) ->setName('primary') ->setLimit(1) @@ -189,7 +189,7 @@ final class PhabricatorOwnersEditController ->setError($e_primary)) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/usersorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setLabel(pht('Owners')) ->setName('owners') ->setValue($handles_all_owners)) diff --git a/src/applications/owners/controller/PhabricatorOwnersListController.php b/src/applications/owners/controller/PhabricatorOwnersListController.php index a861a9e933..6f35bef0a5 100644 --- a/src/applications/owners/controller/PhabricatorOwnersListController.php +++ b/src/applications/owners/controller/PhabricatorOwnersListController.php @@ -177,7 +177,7 @@ final class PhabricatorOwnersListController ->setValue($request->getStr('name'))) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/usersorprojects/') + ->setDatasource(new PhabricatorProjectOrUserDatasource()) ->setLimit(1) ->setName('owner') ->setLabel(pht('Owner')) diff --git a/src/applications/project/typeahead/PhabricatorProjectOrUserDatasource.php b/src/applications/project/typeahead/PhabricatorProjectOrUserDatasource.php new file mode 100644 index 0000000000..2024fa3b8b --- /dev/null +++ b/src/applications/project/typeahead/PhabricatorProjectOrUserDatasource.php @@ -0,0 +1,17 @@ + pht('Type a user or project name...'), 'searchowner' => pht('Type a user name...'), 'searchproject' => pht('Type a project name...'), - 'accountsorprojects' => pht('Type a user or project name...'), 'usersprojectsorpackages' => pht('Type a user, project, or package name...'), ); From cab442fe8ce8f0fbbcc609e798eebe7af8795bb0 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:45:21 -0700 Subject: [PATCH 19/44] Modernize "user, project or package" typeahead datasource Summary: Ref T4420. Call this "auditor" since that's what it is. Test Plan: - Edited auditors in auditor search. - Edited auditors in "add auditors" in Diffusion. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9888 --- src/__phutil_library_map__.php | 2 ++ .../query/PhabricatorCommitSearchEngine.php | 2 +- .../controller/DiffusionCommitController.php | 5 +++-- .../typeahead/DiffusionAuditorDatasource.php | 22 +++++++++++++++++++ ...torTypeaheadCommonDatasourceController.php | 18 --------------- .../control/AphrontFormTokenizerControl.php | 2 -- 6 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 src/applications/diffusion/typeahead/DiffusionAuditorDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 23efd54c85..c1997e3206 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -465,6 +465,7 @@ phutil_register_library_map(array( 'DifferentialUnitTestResult' => 'applications/differential/constants/DifferentialUnitTestResult.php', 'DifferentialViewPolicyField' => 'applications/differential/customfield/DifferentialViewPolicyField.php', 'DiffusionArcanistProjectDatasource' => 'applications/diffusion/typeahead/DiffusionArcanistProjectDatasource.php', + 'DiffusionAuditorDatasource' => 'applications/diffusion/typeahead/DiffusionAuditorDatasource.php', 'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php', 'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php', 'DiffusionBrowseController' => 'applications/diffusion/controller/DiffusionBrowseController.php', @@ -3186,6 +3187,7 @@ phutil_register_library_map(array( 'DifferentialUnitField' => 'DifferentialCustomField', 'DifferentialViewPolicyField' => 'DifferentialCoreCustomField', 'DiffusionArcanistProjectDatasource' => 'PhabricatorTypeaheadDatasource', + 'DiffusionAuditorDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'DiffusionBranchTableController' => 'DiffusionController', 'DiffusionBranchTableView' => 'DiffusionView', 'DiffusionBrowseController' => 'DiffusionController', diff --git a/src/applications/audit/query/PhabricatorCommitSearchEngine.php b/src/applications/audit/query/PhabricatorCommitSearchEngine.php index c448d458f2..cc665358be 100644 --- a/src/applications/audit/query/PhabricatorCommitSearchEngine.php +++ b/src/applications/audit/query/PhabricatorCommitSearchEngine.php @@ -85,7 +85,7 @@ final class PhabricatorCommitSearchEngine $form ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/usersprojectsorpackages/') + ->setDatasource(new DiffusionAuditorDatasource()) ->setName('auditorPHIDs') ->setLabel(pht('Auditors')) ->setValue(array_select_keys($handles, $auditor_phids))) diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 3e672c19f7..86f3996135 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -772,6 +772,7 @@ final class DiffusionCommitController extends DiffusionController { require_celerity_resource('phabricator-transaction-view-css'); $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + $auditor_source = new DiffusionAuditorDatasource(); Javelin::initBehavior( 'differential-add-reviewers-and-ccs', @@ -779,9 +780,9 @@ final class DiffusionCommitController extends DiffusionController { 'dynamic' => array( 'add-auditors-tokenizer' => array( 'actions' => array('add_auditors' => 1), - 'src' => '/typeahead/common/usersprojectsorpackages/', + 'src' => $auditor_source->getDatasourceURI(), 'row' => 'add-auditors', - 'placeholder' => pht('Type a user, project, or package name...'), + 'placeholder' => $auditor_source->getPlaceholderText(), ), 'add-ccs-tokenizer' => array( 'actions' => array('add_ccs' => 1), diff --git a/src/applications/diffusion/typeahead/DiffusionAuditorDatasource.php b/src/applications/diffusion/typeahead/DiffusionAuditorDatasource.php new file mode 100644 index 0000000000..ae0eff9138 --- /dev/null +++ b/src/applications/diffusion/typeahead/DiffusionAuditorDatasource.php @@ -0,0 +1,22 @@ +loadAll(); - foreach ($packages as $package) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setIcon('fa-list-alt bluegrey') - ->setName($package->getName()) - ->setURI('/owners/package/'.$package->getID().'/') - ->setPHID($package->getPHID()); - } - } - if ($need_applications) { $applications = PhabricatorApplication::getAllInstalledApplications(); foreach ($applications as $application) { diff --git a/src/view/form/control/AphrontFormTokenizerControl.php b/src/view/form/control/AphrontFormTokenizerControl.php index 04f824338e..258071a4a4 100644 --- a/src/view/form/control/AphrontFormTokenizerControl.php +++ b/src/view/form/control/AphrontFormTokenizerControl.php @@ -97,8 +97,6 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $map = array( 'searchowner' => pht('Type a user name...'), 'searchproject' => pht('Type a project name...'), - 'usersprojectsorpackages' => - pht('Type a user, project, or package name...'), ); return idx($map, $request); From 0a3a3eae00e7b67c89a236562bd573e5f2ec9920 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:48:36 -0700 Subject: [PATCH 20/44] Modernize global search typeahead datasource Summary: Ref T4420. Bring the global search up to date. Test Plan: Typed various things into global search. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9889 --- src/__phutil_library_map__.php | 6 ++ .../typeahead/DiffusionSymbolDatasource.php | 47 +++++++++++ .../PhabricatorApplicationDatasource.php | 43 ++++++++++ .../typeahead/PhabricatorPeopleDatasource.php | 31 ++++--- .../typeahead/PhabricatorSearchDatasource.php | 24 ++++++ ...torTypeaheadCommonDatasourceController.php | 82 +------------------ .../menu/PhabricatorMainMenuSearchView.php | 4 +- 7 files changed, 142 insertions(+), 95 deletions(-) create mode 100644 src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php create mode 100644 src/applications/meta/typeahead/PhabricatorApplicationDatasource.php create mode 100644 src/applications/search/typeahead/PhabricatorSearchDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index c1997e3206..1010f952da 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -592,6 +592,7 @@ phutil_register_library_map(array( 'DiffusionSvnRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionSvnRawDiffQuery.php', 'DiffusionSvnRequest' => 'applications/diffusion/request/DiffusionSvnRequest.php', 'DiffusionSymbolController' => 'applications/diffusion/controller/DiffusionSymbolController.php', + 'DiffusionSymbolDatasource' => 'applications/diffusion/typeahead/DiffusionSymbolDatasource.php', 'DiffusionSymbolQuery' => 'applications/diffusion/query/DiffusionSymbolQuery.php', 'DiffusionTagListController' => 'applications/diffusion/controller/DiffusionTagListController.php', 'DiffusionTagListView' => 'applications/diffusion/view/DiffusionTagListView.php', @@ -1150,6 +1151,7 @@ phutil_register_library_map(array( 'PhabricatorApplicationCountdown' => 'applications/countdown/application/PhabricatorApplicationCountdown.php', 'PhabricatorApplicationDaemons' => 'applications/daemon/application/PhabricatorApplicationDaemons.php', 'PhabricatorApplicationDashboard' => 'applications/dashboard/application/PhabricatorApplicationDashboard.php', + 'PhabricatorApplicationDatasource' => 'applications/meta/typeahead/PhabricatorApplicationDatasource.php', 'PhabricatorApplicationDetailViewController' => 'applications/meta/controller/PhabricatorApplicationDetailViewController.php', 'PhabricatorApplicationDifferential' => 'applications/differential/application/PhabricatorApplicationDifferential.php', 'PhabricatorApplicationDiffusion' => 'applications/diffusion/application/PhabricatorApplicationDiffusion.php', @@ -2157,6 +2159,7 @@ phutil_register_library_map(array( 'PhabricatorSearchConfigOptions' => 'applications/search/config/PhabricatorSearchConfigOptions.php', 'PhabricatorSearchController' => 'applications/search/controller/PhabricatorSearchController.php', 'PhabricatorSearchDAO' => 'applications/search/storage/PhabricatorSearchDAO.php', + 'PhabricatorSearchDatasource' => 'applications/search/typeahead/PhabricatorSearchDatasource.php', 'PhabricatorSearchDeleteController' => 'applications/search/controller/PhabricatorSearchDeleteController.php', 'PhabricatorSearchDocument' => 'applications/search/storage/document/PhabricatorSearchDocument.php', 'PhabricatorSearchDocumentField' => 'applications/search/storage/document/PhabricatorSearchDocumentField.php', @@ -3301,6 +3304,7 @@ phutil_register_library_map(array( 'DiffusionSvnRawDiffQuery' => 'DiffusionRawDiffQuery', 'DiffusionSvnRequest' => 'DiffusionRequest', 'DiffusionSymbolController' => 'DiffusionController', + 'DiffusionSymbolDatasource' => 'PhabricatorTypeaheadDatasource', 'DiffusionSymbolQuery' => 'PhabricatorOffsetPagedQuery', 'DiffusionTagListController' => 'DiffusionController', 'DiffusionTagListView' => 'DiffusionView', @@ -3924,6 +3928,7 @@ phutil_register_library_map(array( 'PhabricatorApplicationCountdown' => 'PhabricatorApplication', 'PhabricatorApplicationDaemons' => 'PhabricatorApplication', 'PhabricatorApplicationDashboard' => 'PhabricatorApplication', + 'PhabricatorApplicationDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorApplicationDetailViewController' => 'PhabricatorApplicationsController', 'PhabricatorApplicationDifferential' => 'PhabricatorApplication', 'PhabricatorApplicationDiffusion' => 'PhabricatorApplication', @@ -5004,6 +5009,7 @@ phutil_register_library_map(array( 'PhabricatorSearchConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorSearchController' => 'PhabricatorSearchBaseController', 'PhabricatorSearchDAO' => 'PhabricatorLiskDAO', + 'PhabricatorSearchDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorSearchDeleteController' => 'PhabricatorSearchBaseController', 'PhabricatorSearchDocument' => 'PhabricatorSearchDAO', 'PhabricatorSearchDocumentField' => 'PhabricatorSearchDAO', diff --git a/src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php b/src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php new file mode 100644 index 0000000000..bfc34806f9 --- /dev/null +++ b/src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php @@ -0,0 +1,47 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + if (strlen($raw_query)) { + $symbols = id(new DiffusionSymbolQuery()) + ->setNamePrefix($raw_query) + ->setLimit(15) + ->needArcanistProjects(true) + ->needRepositories(true) + ->needPaths(true) + ->execute(); + foreach ($symbols as $symbol) { + $lang = $symbol->getSymbolLanguage(); + $name = $symbol->getSymbolName(); + $type = $symbol->getSymbolType(); + $proj = $symbol->getArcanistProject()->getName(); + + $results[] = id(new PhabricatorTypeaheadResult()) + ->setName($name) + ->setURI($symbol->getURI()) + ->setPHID(md5($symbol->getURI())) // Just needs to be unique. + ->setDisplayName($name) + ->setDisplayType(strtoupper($lang).' '.ucwords($type).' ('.$proj.')') + ->setPriorityType('symb'); + } + } + + return $results; + } + +} diff --git a/src/applications/meta/typeahead/PhabricatorApplicationDatasource.php b/src/applications/meta/typeahead/PhabricatorApplicationDatasource.php new file mode 100644 index 0000000000..f092b2a81d --- /dev/null +++ b/src/applications/meta/typeahead/PhabricatorApplicationDatasource.php @@ -0,0 +1,43 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $applications = PhabricatorApplication::getAllInstalledApplications(); + foreach ($applications as $application) { + $uri = $application->getTypeaheadURI(); + if (!$uri) { + continue; + } + $name = $application->getName().' '.$application->getShortDescription(); + $img = 'apps-'.$application->getIconName().'-dark-large'; + $results[] = id(new PhabricatorTypeaheadResult()) + ->setName($name) + ->setURI($uri) + ->setPHID($application->getPHID()) + ->setPriorityString($application->getName()) + ->setDisplayName($application->getName()) + ->setDisplayType($application->getShortDescription()) + ->setImageuRI($application->getIconURI()) + ->setPriorityType('apps') + ->setImageSprite('phabricator-search-icon sprite-apps-large '.$img); + } + + return $results; + } + +} diff --git a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php index 26e7cbe9f2..5b1a91d953 100644 --- a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php +++ b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php @@ -3,6 +3,18 @@ final class PhabricatorPeopleDatasource extends PhabricatorTypeaheadDatasource { + private $enrichResults; + + /** + * Controls enriched rendering, for global search. This is a bit hacky and + * should probably be handled in a more general way, but is fairly reasonable + * for now. + */ + public function setEnrichResults($enrich) { + $this->enrichResults = $enrich; + return $this; + } + public function getPlaceholderText() { return pht('Type a username...'); } @@ -71,16 +83,14 @@ final class PhabricatorPeopleDatasource } } - // TODO: Restore this when mainsearch moves here. - /* - - if ($need_rich_data) { + if ($this->enrichResults && $users) { $phids = mpull($users, 'getPHID'); - $handles = $this->loadViewerHandles($phids); + $handles = id(new PhabricatorHandleQuery()) + ->setViewer($viewer) + ->withPHIDs($phids) + ->execute(); } - */ - foreach ($users as $user) { $closed = null; if ($user->getIsDisabled()) { @@ -98,10 +108,7 @@ final class PhabricatorPeopleDatasource ->setPriorityType('user') ->setClosed($closed); - // TODO: Restore this too. - /* - - if ($need_rich_data) { + if ($this->enrichResults) { $display_type = 'User'; if ($user->getIsAdmin()) { $display_type = 'Administrator'; @@ -110,8 +117,6 @@ final class PhabricatorPeopleDatasource $result->setImageURI($handles[$user->getPHID()]->getImageURI()); } - */ - $results[] = $result; } diff --git a/src/applications/search/typeahead/PhabricatorSearchDatasource.php b/src/applications/search/typeahead/PhabricatorSearchDatasource.php new file mode 100644 index 0000000000..9cbd8d477a --- /dev/null +++ b/src/applications/search/typeahead/PhabricatorSearchDatasource.php @@ -0,0 +1,24 @@ +setEnrichResults(true), + new PhabricatorProjectDatasource(), + new PhabricatorApplicationDatasource(), + new PhabricatorTypeaheadMonogramDatasource(), + new DiffusionSymbolDatasource(), + ); + } + +} diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index 300d265a2c..a29d461c3b 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -19,24 +19,12 @@ final class PhabricatorTypeaheadCommonDatasourceController $query = $request->getStr('q'); $raw_query = $request->getStr('raw'); - $need_rich_data = false; - $need_users = false; - $need_applications = false; $need_projs = false; $need_upforgrabs = false; $need_noproject = false; - $need_symbols = false; - $need_jump_objects = false; + $need_rich_data = false; switch ($this->type) { - case 'mainsearch': - $need_users = true; - $need_applications = true; - $need_rich_data = true; - $need_symbols = true; - $need_projs = true; - $need_jump_objects = true; - break; case 'searchowner': $need_users = true; $need_upforgrabs = true; @@ -186,74 +174,6 @@ final class PhabricatorTypeaheadCommonDatasourceController } } - if ($need_applications) { - $applications = PhabricatorApplication::getAllInstalledApplications(); - foreach ($applications as $application) { - $uri = $application->getTypeaheadURI(); - if (!$uri) { - continue; - } - $name = $application->getName().' '.$application->getShortDescription(); - $img = 'apps-'.$application->getIconName().'-dark-large'; - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName($name) - ->setURI($uri) - ->setPHID($application->getPHID()) - ->setPriorityString($application->getName()) - ->setDisplayName($application->getName()) - ->setDisplayType($application->getShortDescription()) - ->setImageuRI($application->getIconURI()) - ->setPriorityType('apps') - ->setImageSprite('phabricator-search-icon sprite-apps-large '.$img); - } - } - - if ($need_symbols) { - $symbols = id(new DiffusionSymbolQuery()) - ->setNamePrefix($query) - ->setLimit(15) - ->needArcanistProjects(true) - ->needRepositories(true) - ->needPaths(true) - ->execute(); - foreach ($symbols as $symbol) { - $lang = $symbol->getSymbolLanguage(); - $name = $symbol->getSymbolName(); - $type = $symbol->getSymbolType(); - $proj = $symbol->getArcanistProject()->getName(); - - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName($name) - ->setURI($symbol->getURI()) - ->setPHID(md5($symbol->getURI())) // Just needs to be unique. - ->setDisplayName($name) - ->setDisplayType(strtoupper($lang).' '.ucwords($type).' ('.$proj.')') - ->setPriorityType('symb'); - } - } - - if ($need_jump_objects) { - $objects = id(new PhabricatorObjectQuery()) - ->setViewer($viewer) - ->withNames(array($raw_query)) - ->execute(); - if ($objects) { - $handles = id(new PhabricatorHandleQuery()) - ->setViewer($viewer) - ->withPHIDs(mpull($objects, 'getPHID')) - ->execute(); - $handle = head($handles); - if ($handle) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName($handle->getFullName()) - ->setDisplayType($handle->getTypeName()) - ->setURI($handle->getURI()) - ->setPHID($handle->getPHID()) - ->setPriorityType('jump'); - } - } - } - $content = mpull($results, 'getWireFormat'); if ($request->isAjax()) { diff --git a/src/view/page/menu/PhabricatorMainMenuSearchView.php b/src/view/page/menu/PhabricatorMainMenuSearchView.php index 3c4b677c9f..9c8058c81e 100644 --- a/src/view/page/menu/PhabricatorMainMenuSearchView.php +++ b/src/view/page/menu/PhabricatorMainMenuSearchView.php @@ -35,13 +35,15 @@ final class PhabricatorMainMenuSearchView extends AphrontView { ), ''); + $search_datasource = new PhabricatorSearchDatasource(); + Javelin::initBehavior( 'phabricator-search-typeahead', array( 'id' => $target_id, 'input' => $search_id, 'button' => $button_id, - 'src' => '/typeahead/common/mainsearch/', + 'src' => $search_datasource->getDatasourceURI(), 'limit' => 10, 'placeholder' => pht('Search'), )); From 27daa116c2ecf6c5cf61bc543961139fa90917ed Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:48:50 -0700 Subject: [PATCH 21/44] Remove "searchproject" typeahead datasource Summary: Ref T4420. This is just "project", plus the special "no project" token, but that doesn't actually work. Replace it with a normal project typeahead. This is only used in Maniphest's reports. Test Plan: Searched for a couple of projects in reports. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9890 --- .../controller/ManiphestReportController.php | 2 +- ...torTypeaheadCommonDatasourceController.php | 39 ------------------- .../control/AphrontFormTokenizerControl.php | 1 - 3 files changed, 1 insertion(+), 41 deletions(-) diff --git a/src/applications/maniphest/controller/ManiphestReportController.php b/src/applications/maniphest/controller/ManiphestReportController.php index 6fd69d432c..dd43b2c043 100644 --- a/src/applications/maniphest/controller/ManiphestReportController.php +++ b/src/applications/maniphest/controller/ManiphestReportController.php @@ -321,7 +321,7 @@ final class ManiphestReportController extends ManiphestController { ->setUser($user) ->appendChild( id(new AphrontFormTokenizerControl()) - ->setDatasource('/typeahead/common/searchproject/') + ->setDatasource(new PhabricatorProjectDatasource()) ->setLabel(pht('Project')) ->setLimit(1) ->setName('set_project') diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php index a29d461c3b..dc54c9b7d6 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php @@ -20,19 +20,13 @@ final class PhabricatorTypeaheadCommonDatasourceController $raw_query = $request->getStr('raw'); $need_users = false; - $need_projs = false; $need_upforgrabs = false; - $need_noproject = false; $need_rich_data = false; switch ($this->type) { case 'searchowner': $need_users = true; $need_upforgrabs = true; break; - case 'searchproject': - $need_projs = true; - $need_noproject = true; - break; } $results = array(); @@ -43,13 +37,6 @@ final class PhabricatorTypeaheadCommonDatasourceController ->setPHID(ManiphestTaskOwner::OWNER_UP_FOR_GRABS); } - if ($need_noproject) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName('noproject (No Project)') - ->setPHID(ManiphestTaskOwner::PROJECT_NO_PROJECT); - } - - if ($need_users) { $columns = array( 'isSystemAgent', @@ -148,32 +135,6 @@ final class PhabricatorTypeaheadCommonDatasourceController } } - if ($need_projs) { - $projs = id(new PhabricatorProjectQuery()) - ->setViewer($viewer) - ->needImages(true) - ->execute(); - foreach ($projs as $proj) { - $closed = null; - if ($proj->isArchived()) { - $closed = pht('Archived'); - } - - $proj_result = id(new PhabricatorTypeaheadResult()) - ->setName($proj->getName()) - ->setDisplayType('Project') - ->setURI('/project/view/'.$proj->getID().'/') - ->setPHID($proj->getPHID()) - ->setIcon($proj->getIcon()) - ->setPriorityType('proj') - ->setClosed($closed); - - $proj_result->setImageURI($proj->getProfileImageURI()); - - $results[] = $proj_result; - } - } - $content = mpull($results, 'getWireFormat'); if ($request->isAjax()) { diff --git a/src/view/form/control/AphrontFormTokenizerControl.php b/src/view/form/control/AphrontFormTokenizerControl.php index 258071a4a4..f342cd3236 100644 --- a/src/view/form/control/AphrontFormTokenizerControl.php +++ b/src/view/form/control/AphrontFormTokenizerControl.php @@ -96,7 +96,6 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $map = array( 'searchowner' => pht('Type a user name...'), - 'searchproject' => pht('Type a project name...'), ); return idx($map, $request); From 7f0fb63c445027cd5c9148bd9d8f7d4263b68802 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:49:00 -0700 Subject: [PATCH 22/44] Modernize "owner" typeahead datasource Summary: Ref T4420. This one is users plus "upforgrabs". I renamed that to "none" and gave it a special visual style to make it more discoverable. Future diffs will improve this. Test Plan: - Used it in global search. - Used it in batch editor. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9891 --- src/__phutil_library_map__.php | 6 +- .../ManiphestBatchEditController.php | 6 +- ...abricatorSearchApplicationSearchEngine.php | 2 +- .../PhabricatorApplicationTypeahead.php | 2 - ...torTypeaheadCommonDatasourceController.php | 179 ------------------ .../PhabricatorTypeaheadNoOwnerDatasource.php | 28 +++ .../PhabricatorTypeaheadOwnerDatasource.php | 17 ++ .../control/AphrontFormTokenizerControl.php | 34 +--- 8 files changed, 60 insertions(+), 214 deletions(-) delete mode 100644 src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php create mode 100644 src/applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php create mode 100644 src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 1010f952da..86ff4fc8cc 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2333,12 +2333,13 @@ phutil_register_library_map(array( 'PhabricatorTranslationsConfigOptions' => 'applications/config/option/PhabricatorTranslationsConfigOptions.php', 'PhabricatorTrivialTestCase' => 'infrastructure/testing/__tests__/PhabricatorTrivialTestCase.php', 'PhabricatorTwoColumnExample' => 'applications/uiexample/examples/PhabricatorTwoColumnExample.php', - 'PhabricatorTypeaheadCommonDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php', 'PhabricatorTypeaheadCompositeDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php', 'PhabricatorTypeaheadDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php', 'PhabricatorTypeaheadDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadDatasourceController.php', 'PhabricatorTypeaheadModularDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php', 'PhabricatorTypeaheadMonogramDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadMonogramDatasource.php', + 'PhabricatorTypeaheadNoOwnerDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php', + 'PhabricatorTypeaheadOwnerDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php', 'PhabricatorTypeaheadResult' => 'applications/typeahead/storage/PhabricatorTypeaheadResult.php', 'PhabricatorTypeaheadRuntimeCompositeDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadRuntimeCompositeDatasource.php', 'PhabricatorUIConfigOptions' => 'applications/config/option/PhabricatorUIConfigOptions.php', @@ -5173,12 +5174,13 @@ phutil_register_library_map(array( 'PhabricatorTranslationsConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorTrivialTestCase' => 'PhabricatorTestCase', 'PhabricatorTwoColumnExample' => 'PhabricatorUIExample', - 'PhabricatorTypeaheadCommonDatasourceController' => 'PhabricatorTypeaheadDatasourceController', 'PhabricatorTypeaheadCompositeDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorTypeaheadDatasource' => 'Phobject', 'PhabricatorTypeaheadDatasourceController' => 'PhabricatorController', 'PhabricatorTypeaheadModularDatasourceController' => 'PhabricatorTypeaheadDatasourceController', 'PhabricatorTypeaheadMonogramDatasource' => 'PhabricatorTypeaheadDatasource', + 'PhabricatorTypeaheadNoOwnerDatasource' => 'PhabricatorTypeaheadDatasource', + 'PhabricatorTypeaheadOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorTypeaheadRuntimeCompositeDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorUIConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorUIExampleRenderController' => 'PhabricatorController', diff --git a/src/applications/maniphest/controller/ManiphestBatchEditController.php b/src/applications/maniphest/controller/ManiphestBatchEditController.php index 59f361931a..0488000b3a 100644 --- a/src/applications/maniphest/controller/ManiphestBatchEditController.php +++ b/src/applications/maniphest/controller/ManiphestBatchEditController.php @@ -63,6 +63,7 @@ final class ManiphestBatchEditController extends ManiphestController { $projects_source = new PhabricatorProjectDatasource(); $mailable_source = new PhabricatorMetaMTAMailableDatasource(); + $owner_source = new PhabricatorTypeaheadOwnerDatasource(); require_celerity_resource('maniphest-batch-editor'); Javelin::initBehavior( @@ -76,9 +77,8 @@ final class ManiphestBatchEditController extends ManiphestController { 'placeholder' => $projects_source->getPlaceholderText(), ), 'owner' => array( - 'src' => '/typeahead/common/searchowner/', - 'placeholder' => pht( - 'Type a user name or "upforgrabs" to unassign...'), + 'src' => $owner_source->getDatasourceURI(), + 'placeholder' => $owner_source->getPlaceholderText(), 'limit' => 1, ), 'cc' => array( diff --git a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php index 76c7b4013f..57aa9c4db4 100644 --- a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php +++ b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php @@ -142,7 +142,7 @@ final class PhabricatorSearchApplicationSearchEngine id(new AphrontFormTokenizerControl()) ->setName('ownerPHIDs') ->setLabel('Owners') - ->setDatasource('/typeahead/common/searchowner/') + ->setDatasource(new PhabricatorTypeaheadOwnerDatasource()) ->setValue($owner_handles)) ->appendChild( id(new AphrontFormCheckboxControl()) diff --git a/src/applications/typeahead/application/PhabricatorApplicationTypeahead.php b/src/applications/typeahead/application/PhabricatorApplicationTypeahead.php index 5a8a0b69f2..0e5c0afd4f 100644 --- a/src/applications/typeahead/application/PhabricatorApplicationTypeahead.php +++ b/src/applications/typeahead/application/PhabricatorApplicationTypeahead.php @@ -5,8 +5,6 @@ final class PhabricatorApplicationTypeahead extends PhabricatorApplication { public function getRoutes() { return array( '/typeahead/' => array( - 'common/(?P\w+)/' - => 'PhabricatorTypeaheadCommonDatasourceController', 'class/(?:(?P\w+)/)?' => 'PhabricatorTypeaheadModularDatasourceController', ), diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php deleted file mode 100644 index dc54c9b7d6..0000000000 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadCommonDatasourceController.php +++ /dev/null @@ -1,179 +0,0 @@ -type = $data['type']; - } - - public function processRequest() { - $request = $this->getRequest(); - $viewer = $request->getUser(); - $query = $request->getStr('q'); - $raw_query = $request->getStr('raw'); - - $need_users = false; - $need_upforgrabs = false; - $need_rich_data = false; - switch ($this->type) { - case 'searchowner': - $need_users = true; - $need_upforgrabs = true; - break; - } - - $results = array(); - - if ($need_upforgrabs) { - $results[] = id(new PhabricatorTypeaheadResult()) - ->setName('upforgrabs (Up For Grabs)') - ->setPHID(ManiphestTaskOwner::OWNER_UP_FOR_GRABS); - } - - if ($need_users) { - $columns = array( - 'isSystemAgent', - 'isAdmin', - 'isDisabled', - 'userName', - 'realName', - 'phid'); - - if ($query) { - // This is an arbitrary limit which is just larger than any limit we - // actually use in the application. - - // TODO: The datasource should pass this in the query. - $limit = 15; - - $user_table = new PhabricatorUser(); - $conn_r = $user_table->establishConnection('r'); - $ids = queryfx_all( - $conn_r, - 'SELECT id FROM %T WHERE username LIKE %> - ORDER BY username ASC LIMIT %d', - $user_table->getTableName(), - $query, - $limit); - $ids = ipull($ids, 'id'); - - if (count($ids) < $limit) { - // If we didn't find enough username hits, look for real name hits. - // We need to pull the entire pagesize so that we end up with the - // right number of items if this query returns many duplicate IDs - // that we've already selected. - - $realname_ids = queryfx_all( - $conn_r, - 'SELECT DISTINCT userID FROM %T WHERE token LIKE %> - ORDER BY token ASC LIMIT %d', - PhabricatorUser::NAMETOKEN_TABLE, - $query, - $limit); - $realname_ids = ipull($realname_ids, 'userID'); - $ids = array_merge($ids, $realname_ids); - - $ids = array_unique($ids); - $ids = array_slice($ids, 0, $limit); - } - - // Always add the logged-in user because some tokenizers autosort them - // first. They'll be filtered out on the client side if they don't - // match the query. - $ids[] = $request->getUser()->getID(); - - if ($ids) { - $users = id(new PhabricatorUser())->loadColumnsWhere( - $columns, - 'id IN (%Ld)', - $ids); - } else { - $users = array(); - } - } else { - $users = id(new PhabricatorUser())->loadColumns($columns); - } - - if ($need_rich_data) { - $phids = mpull($users, 'getPHID'); - $handles = $this->loadViewerHandles($phids); - } - - foreach ($users as $user) { - $closed = null; - if ($user->getIsDisabled()) { - $closed = pht('Disabled'); - } else if ($user->getIsSystemAgent()) { - $closed = pht('Bot/Script'); - } - - $result = id(new PhabricatorTypeaheadResult()) - ->setName($user->getFullName()) - ->setURI('/p/'.$user->getUsername()) - ->setPHID($user->getPHID()) - ->setPriorityString($user->getUsername()) - ->setIcon('fa-user bluegrey') - ->setPriorityType('user') - ->setClosed($closed); - - if ($need_rich_data) { - $display_type = 'User'; - if ($user->getIsAdmin()) { - $display_type = 'Administrator'; - } - $result->setDisplayType($display_type); - $result->setImageURI($handles[$user->getPHID()]->getImageURI()); - } - $results[] = $result; - } - } - - $content = mpull($results, 'getWireFormat'); - - if ($request->isAjax()) { - return id(new AphrontAjaxResponse())->setContent($content); - } - - // If there's a non-Ajax request to this endpoint, show results in a tabular - // format to make it easier to debug typeahead output. - - $rows = array(); - foreach ($results as $result) { - $wire = $result->getWireFormat(); - $rows[] = $wire; - } - - $table = new AphrontTableView($rows); - $table->setHeaders( - array( - 'Name', - 'URI', - 'PHID', - 'Priority', - 'Display Name', - 'Display Type', - 'Image URI', - 'Priority Type', - 'Sprite Class', - )); - - $panel = new AphrontPanelView(); - $panel->setHeader('Typeahead Results'); - $panel->appendChild($table); - - return $this->buildStandardPageResponse( - $panel, - array( - 'title' => pht('Typeahead Results'), - 'device' => true - )); - } - -} diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php new file mode 100644 index 0000000000..76dd3148d8 --- /dev/null +++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php @@ -0,0 +1,28 @@ +getViewer(); + $raw_query = $this->getRawQuery(); + + $results = array(); + + $results[] = id(new PhabricatorTypeaheadResult()) + ->setName(pht('None')) + ->setIcon('fa-ban orange') + ->setPHID(ManiphestTaskOwner::OWNER_UP_FOR_GRABS); + + return $results; + } + +} diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php new file mode 100644 index 0000000000..a2aaf4f991 --- /dev/null +++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php @@ -0,0 +1,17 @@ +datasource = $datasource; return $this; } @@ -43,8 +43,11 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $id = celerity_generate_unique_node_id(); } + $placeholder = null; if (!strlen($this->placeholder)) { - $placeholder = $this->getDefaultPlaceholder(); + if ($this->datasource) { + $placeholder = $this->datasource->getPlaceholderText(); + } } else { $placeholder = $this->placeholder; } @@ -59,10 +62,9 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { $username = $this->user->getUsername(); } - if ($this->datasource instanceof PhabricatorTypeaheadDatasource) { + $datasource_uri = null; + if ($this->datasource) { $datasource_uri = $this->datasource->getDatasourceURI(); - } else { - $datasource_uri = $this->datasource; } if (!$this->disableBehavior) { @@ -80,26 +82,4 @@ final class AphrontFormTokenizerControl extends AphrontFormControl { return $template->render(); } - private function getDefaultPlaceholder() { - $datasource = $this->datasource; - - if ($datasource instanceof PhabricatorTypeaheadDatasource) { - return $datasource->getPlaceholderText(); - } - - $matches = null; - if (!preg_match('@^/typeahead/common/(.*)/$@', $datasource, $matches)) { - return null; - } - - $request = $matches[1]; - - $map = array( - 'searchowner' => pht('Type a user name...'), - ); - - return idx($map, $request); - } - - } From b8d604acaf84e967ee764f13462d84594f67bfa7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:49:11 -0700 Subject: [PATCH 23/44] Make typeahead datasources default to PHID type icons Summary: Ref T4420. If a datasource does not specify an icon explicitly, check if the PHID type has a default, and use that. This leaves us with only Projects and some special stuff setting explicit icons, and reduces code duplication. Test Plan: Used typeahead to find all affected object types. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9894 --- .../DiffusionRepositoryDatasource.php | 3 +- .../typeahead/LegalpadDocumentDatasource.php | 1 - .../typeahead/PhabricatorMacroDatasource.php | 3 +- .../PhabricatorMailingListPHIDTypeList.php | 4 +++ .../phid/PhabricatorOwnersPHIDTypePackage.php | 4 +++ .../PhabricatorOwnersPackageDatasource.php | 1 - .../typeahead/PhabricatorPeopleDatasource.php | 1 - .../PhabricatorProjectDatasource.php | 2 +- .../storage/PhabricatorTypeaheadResult.php | 30 ++++++++++++++++++- 9 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php index cdaa5f7c6c..3cbf202eb6 100644 --- a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php +++ b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php @@ -25,8 +25,7 @@ final class DiffusionRepositoryDatasource ->setName($repo->getMonogram().' '.$repo->getName()) ->setURI('/diffusion/'.$repo->getCallsign().'/') ->setPHID($repo->getPHID()) - ->setPriorityString($repo->getMonogram()) - ->setIcon('fa-database bluegrey'); + ->setPriorityString($repo->getMonogram()); } return $results; diff --git a/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php b/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php index e266dca640..ccb527dfa0 100644 --- a/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php +++ b/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php @@ -23,7 +23,6 @@ final class LegalpadDocumentDatasource foreach ($documents as $document) { $results[] = id(new PhabricatorTypeaheadResult()) ->setPHID($document->getPHID()) - ->setIcon('fa-file-text-o') ->setName($document->getMonogram().' '.$document->getTitle()); } diff --git a/src/applications/macro/typeahead/PhabricatorMacroDatasource.php b/src/applications/macro/typeahead/PhabricatorMacroDatasource.php index a6c84d9cce..6b7078b410 100644 --- a/src/applications/macro/typeahead/PhabricatorMacroDatasource.php +++ b/src/applications/macro/typeahead/PhabricatorMacroDatasource.php @@ -25,8 +25,7 @@ final class PhabricatorMacroDatasource foreach ($macros as $macro) { $results[] = id(new PhabricatorTypeaheadResult()) ->setPHID($macro->getPHID()) - ->setName($macro->getName()) - ->setIcon('fa-meh-o bluegrey'); + ->setName($macro->getName()); } return $results; diff --git a/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php b/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php index df814dfa3a..3371d2cf0f 100644 --- a/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php +++ b/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php @@ -12,6 +12,10 @@ final class PhabricatorMailingListPHIDTypeList extends PhabricatorPHIDType { return pht('Mailing List'); } + public function getTypeIcon() { + return 'fa-envelope-o'; + } + public function newObject() { return new PhabricatorMetaMTAMailingList(); } diff --git a/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php b/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php index b82b47a9ea..6aff840c22 100644 --- a/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php +++ b/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php @@ -12,6 +12,10 @@ final class PhabricatorOwnersPHIDTypePackage extends PhabricatorPHIDType { return pht('Owners Package'); } + public function getTypeIcon() { + return 'fa-list-alt'; + } + public function newObject() { return new PhabricatorOwnersPackage(); } diff --git a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php index edbcf758ce..7d681bc2cc 100644 --- a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php +++ b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php @@ -23,7 +23,6 @@ final class PhabricatorOwnersPackageDatasource foreach ($packages as $package) { $results[] = id(new PhabricatorTypeaheadResult()) - ->setIcon('fa-list-alt bluegrey') ->setName($package->getName()) ->setURI('/owners/package/'.$package->getID().'/') ->setPHID($package->getPHID()); diff --git a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php index 5b1a91d953..d0f9aa2d18 100644 --- a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php +++ b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php @@ -104,7 +104,6 @@ final class PhabricatorPeopleDatasource ->setURI('/p/'.$user->getUsername()) ->setPHID($user->getPHID()) ->setPriorityString($user->getUsername()) - ->setIcon('fa-user bluegrey') ->setPriorityType('user') ->setClosed($closed); diff --git a/src/applications/project/typeahead/PhabricatorProjectDatasource.php b/src/applications/project/typeahead/PhabricatorProjectDatasource.php index 8b2343132d..f9bba5c33f 100644 --- a/src/applications/project/typeahead/PhabricatorProjectDatasource.php +++ b/src/applications/project/typeahead/PhabricatorProjectDatasource.php @@ -32,7 +32,7 @@ final class PhabricatorProjectDatasource ->setDisplayType('Project') ->setURI('/tag/'.$proj->getPrimarySlug().'/') ->setPHID($proj->getPHID()) - ->setIcon($proj->getIcon()) + ->setIcon($proj->getIcon().' bluegrey') ->setPriorityType('proj') ->setClosed($closed); diff --git a/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php b/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php index ee4c8609fa..37aa314ce9 100644 --- a/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php +++ b/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php @@ -79,7 +79,7 @@ final class PhabricatorTypeaheadResult { $this->displayType, $this->imageURI ? (string)$this->imageURI : null, $this->priorityType, - $this->icon, + ($this->icon === null) ? $this->getDefaultIcon() : $this->icon, $this->closed, $this->imageSprite ? (string)$this->imageSprite : null, ); @@ -89,4 +89,32 @@ final class PhabricatorTypeaheadResult { return $data; } + /** + * If the datasource did not specify an icon explicitly, try to select a + * default based on PHID type. + */ + private function getDefaultIcon() { + static $icon_map; + if ($icon_map === null) { + $types = PhabricatorPHIDType::getAllTypes(); + + $map = array(); + foreach ($types as $type) { + $icon = $type->getTypeIcon(); + if ($icon !== null) { + $map[$type->getTypeConstant()] = "{$icon} bluegrey"; + } + } + + $icon_map = $map; + } + + $phid_type = phid_get_type($this->phid); + if (isset($icon_map[$phid_type])) { + return $icon_map[$phid_type]; + } + + return null; + } + } From c52b3c28e1667beba4cdd35d56e99cabf8006994 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:49:21 -0700 Subject: [PATCH 24/44] Remove partial objects from Lisk Summary: Ref T4420. This was a performance hack introduced long ago to make typeaheads for users a little cheaper. The idea was that you could load some of an object's columns and skip other ones. We now always load users on demand, so the cost of loading the whole objects is very small. No other use cases ever arose for this, and it seems unlikely that they will in the future. Remove it all. Test Plan: - Grepped for `CONFIG_PARTIAL_OBJECTS`. - Grepped for `dirtyFields`. - Grepped for `missingFields`. - Grepped for `resetDirtyFields`. - Grepped for `loadColumns`. - Grepped for `loadColumnsWhere`. - Grepped for `loadRawDataWhere`. - Loaded and saved some lisk objects. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9895 --- .../people/storage/PhabricatorUser.php | 1 - src/infrastructure/storage/lisk/LiskDAO.php | 114 +----------------- 2 files changed, 3 insertions(+), 112 deletions(-) diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index 38c9b421a8..e12bef88f8 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -113,7 +113,6 @@ final class PhabricatorUser public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, - self::CONFIG_PARTIAL_OBJECTS => true, ) + parent::getConfiguration(); } diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php index 3683e35e6f..b3f54d0817 100644 --- a/src/infrastructure/storage/lisk/LiskDAO.php +++ b/src/infrastructure/storage/lisk/LiskDAO.php @@ -168,7 +168,6 @@ abstract class LiskDAO { const CONFIG_TIMESTAMPS = 'timestamps'; const CONFIG_AUX_PHID = 'auxiliary-phid'; const CONFIG_SERIALIZATION = 'col-serialization'; - const CONFIG_PARTIAL_OBJECTS = 'partial-objects'; const CONFIG_BINARY = 'binary'; const SERIALIZATION_NONE = 'id'; @@ -181,8 +180,6 @@ abstract class LiskDAO { const COUNTER_TABLE_NAME = 'lisk_counter'; - private $dirtyFields = array(); - private $missingFields = array(); private static $processIsolationLevel = 0; private static $transactionIsolationLevel = 0; @@ -207,10 +204,6 @@ abstract class LiskDAO { if ($id_key) { $this->$id_key = null; } - - if ($this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS)) { - $this->resetDirtyFields(); - } } @@ -345,16 +338,6 @@ abstract class LiskDAO { * This will cause Lisk to JSON-serialize the 'complex' field before it is * written, and unserialize it when it is read. * - * CONFIG_PARTIAL_OBJECTS - * Sometimes, it is useful to load only some fields of an object (such as - * when you are loading all objects of a class, but only care about a few - * fields). Turning on this option (by setting it to a truthy value) allows - * users of the class to create/use partial objects, but it comes with some - * side effects: your class cannot override the setters and getters provided - * by Lisk (use readField and writeField instead), and you should not - * directly access or assign protected members of your class (use the getters - * and setters). - * * CONFIG_BINARY * You can optionally provide a map of columns to a flag indicating that * they store binary data. These columns will not raise an error when @@ -368,7 +351,6 @@ abstract class LiskDAO { return array( self::CONFIG_IDS => self::IDS_AUTOINCREMENT, self::CONFIG_TIMESTAMPS => true, - self::CONFIG_PARTIAL_OBJECTS => false, ); } @@ -435,18 +417,6 @@ abstract class LiskDAO { return $this->loadAllWhere('1 = 1'); } - /** - * Loads all objects, but only fetches the specified columns. - * - * @param array Array of canonical column names as strings - * @return dict Dictionary of all objects, keyed by ID. - * - * @task load - */ - public function loadColumns(array $columns) { - return $this->loadColumnsWhere($columns, '1 = 1'); - } - /** * Load all objects which match a WHERE clause. You provide everything after @@ -463,30 +433,6 @@ abstract class LiskDAO { * @task load */ public function loadAllWhere($pattern /* , $arg, $arg, $arg ... */) { - $args = func_get_args(); - array_unshift($args, null); - $data = call_user_func_array( - array($this, 'loadRawDataWhere'), - $args); - return $this->loadAllFromArray($data); - } - - /** - * Loads selected columns from objects that match a WHERE clause. You must - * provide everything after the WHERE. See loadAllWhere(). - * - * @param array List of column names. - * @param string queryfx()-style SQL WHERE clause. - * @param ... Zero or more conversions. - * @return dict Dictionary of matching objecks, keyed by ID. - * - * @task load - */ - public function loadColumnsWhere(array $columns, $pattern /* , $args... */) { - if (!$this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS)) { - throw new BadMethodCallException( - 'This class does not support partial objects.'); - } $args = func_get_args(); $data = call_user_func_array( array($this, 'loadRawDataWhere'), @@ -509,7 +455,6 @@ abstract class LiskDAO { */ public function loadOneWhere($pattern /* , $arg, $arg, $arg ... */) { $args = func_get_args(); - array_unshift($args, null); $data = call_user_func_array( array($this, 'loadRawDataWhere'), $args); @@ -528,7 +473,7 @@ abstract class LiskDAO { } - protected function loadRawDataWhere($columns, $pattern /* , $args... */) { + protected function loadRawDataWhere($pattern /* , $args... */) { $connection = $this->establishConnection('r'); $lock_clause = ''; @@ -539,25 +484,10 @@ abstract class LiskDAO { } $args = func_get_args(); - $args = array_slice($args, 2); + $args = array_slice($args, 1); - if (!$columns) { - $column = '*'; - } else { - $column = '%LC'; - $columns[] = $this->getIDKey(); - - $properties = $this->getProperties(); - $this->missingFields = array_diff_key( - array_flip($properties), - array_flip($columns)); - } - - $pattern = 'SELECT '.$column.' FROM %T WHERE '.$pattern.' %Q'; + $pattern = 'SELECT * FROM %T WHERE '.$pattern.' %Q'; array_unshift($args, $this->getTableName()); - if ($columns) { - array_unshift($args, $columns); - } array_push($args, $lock_clause); array_unshift($args, $pattern); @@ -1141,9 +1071,6 @@ abstract class LiskDAO { $this->willSaveObject(); $data = $this->getPropertyValues(); - if ($this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS)) { - $data = array_intersect_key($data, $this->dirtyFields); - } $this->willWriteData($data); $map = array(); @@ -1176,10 +1103,6 @@ abstract class LiskDAO { $this->didWriteData(); - if ($this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS)) { - $this->resetDirtyFields(); - } - return $this; } @@ -1286,10 +1209,6 @@ abstract class LiskDAO { $this->didWriteData(); - if ($this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS)) { - $this->resetDirtyFields(); - } - return $this; } @@ -1680,20 +1599,6 @@ abstract class LiskDAO { } } - /** - * Resets the dirty fields (fields which need to be written on next save/ - * update/insert/replace). If this DAO has timestamps, the modified time - * is always a dirty field. - * - * @task util - */ - private function resetDirtyFields() { - $this->dirtyFields = array(); - if ($this->getConfigOption(self::CONFIG_TIMESTAMPS)) { - $this->dirtyFields['dateModified'] = true; - } - } - /** * Black magic. Builds implied get*() and set*() for all properties. * @@ -1719,10 +1624,6 @@ abstract class LiskDAO { // optimizations. static $dispatch_map = array(); - static $partial = null; - if ($partial === null) { - $partial = $this->getConfigOption(self::CONFIG_PARTIAL_OBJECTS); - } if ($method[0] === 'g') { if (isset($dispatch_map[$method])) { @@ -1738,10 +1639,6 @@ abstract class LiskDAO { $dispatch_map[$method] = $property; } - if ($partial && isset($this->missingFields[$property])) { - throw new Exception("Cannot get field that wasn't loaded: {$property}"); - } - return $this->readField($property); } @@ -1759,11 +1656,6 @@ abstract class LiskDAO { } $dispatch_map[$method] = $property; } - if ($partial) { - // Accept writes to fields that weren't initially loaded - unset($this->missingFields[$property]); - $this->dirtyFields[$property] = true; - } $this->writeField($property, $args[0]); From a592b32ca4b9288156a9d9357ed9bb0217c341e5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:52:58 -0700 Subject: [PATCH 25/44] Share more code between tokenizers and global typeahead Summary: Ref T4420. Fixes T5306. Currently, the main menubar search has a lot of redundant/unshared code. Move some common functions into `JX.Prefab.whatever()` and call them from the main search. The major change here is that we apply the same "only show closed/disabled/archived objects if there are no matching open objects" logic, fixing T5306. Test Plan: - Used normal typeaheads. - Used global search. - Searched for a prefix shared by open and archived projects, didn't see the archived ones until the open ones were exhausted. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5306, T4420 Differential Revision: https://secure.phabricator.com/D9899 --- resources/celerity/map.php | 53 +++--- webroot/rsrc/js/core/Prefab.js | 162 ++++++++++-------- .../rsrc/js/core/behavior-search-typeahead.js | 29 ++-- 3 files changed, 127 insertions(+), 117 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 7d6d649570..d4cc9e001f 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -8,7 +8,7 @@ return array( 'names' => array( 'core.pkg.css' => 'c2c68e64', - 'core.pkg.js' => '80884e9b', + 'core.pkg.js' => '0095fb2c', 'darkconsole.pkg.js' => 'df001cab', 'differential.pkg.css' => '4a93db37', 'differential.pkg.js' => '7528cfc9', @@ -450,7 +450,7 @@ return array( 'rsrc/js/core/KeyboardShortcutManager.js' => 'ad7a69ca', 'rsrc/js/core/MultirowRowManager.js' => '41e47dea', 'rsrc/js/core/Notification.js' => '0c6946e7', - 'rsrc/js/core/Prefab.js' => '41ed7994', + 'rsrc/js/core/Prefab.js' => 'c11bac49', 'rsrc/js/core/ShapedRequest.js' => '7cbe244b', 'rsrc/js/core/TextAreaUtils.js' => 'b3ec3cfc', 'rsrc/js/core/ToolTip.js' => '3915d490', @@ -485,7 +485,7 @@ return array( 'rsrc/js/core/behavior-remarkup-preview.js' => 'f7379f45', 'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e', 'rsrc/js/core/behavior-reveal-content.js' => '60821bc7', - 'rsrc/js/core/behavior-search-typeahead.js' => '5a376f34', + 'rsrc/js/core/behavior-search-typeahead.js' => 'd712ac5f', 'rsrc/js/core/behavior-select-on-click.js' => '4e3e79a6', 'rsrc/js/core/behavior-toggle-class.js' => 'e566f52c', 'rsrc/js/core/behavior-tokenizer.js' => 'b3a4b884', @@ -629,7 +629,7 @@ return array( 'javelin-behavior-phabricator-oncopy' => '2926fff2', 'javelin-behavior-phabricator-remarkup-assist' => 'e32d14ab', 'javelin-behavior-phabricator-reveal-content' => '60821bc7', - 'javelin-behavior-phabricator-search-typeahead' => '5a376f34', + 'javelin-behavior-phabricator-search-typeahead' => 'd712ac5f', 'javelin-behavior-phabricator-show-all-transactions' => '7c273581', 'javelin-behavior-phabricator-tooltips' => '3ee3408b', 'javelin-behavior-phabricator-transaction-comment-form' => '9f7309fb', @@ -737,7 +737,7 @@ return array( 'phabricator-notification-menu-css' => '8ae4a008', 'phabricator-object-selector-css' => '029a133d', 'phabricator-phtize' => 'd254d646', - 'phabricator-prefab' => '41ed7994', + 'phabricator-prefab' => 'c11bac49', 'phabricator-profile-css' => 'b459416e', 'phabricator-remarkup-css' => 'ad4c0676', 'phabricator-search-results-css' => 'f240504c', @@ -1126,18 +1126,6 @@ return array( 2 => 'javelin-dom', 3 => 'javelin-util', ), - '41ed7994' => array( - 0 => 'javelin-install', - 1 => 'javelin-util', - 2 => 'javelin-dom', - 3 => 'javelin-typeahead', - 4 => 'javelin-tokenizer', - 5 => 'javelin-typeahead-preloaded-source', - 6 => 'javelin-typeahead-ondemand-source', - 7 => 'javelin-dom', - 8 => 'javelin-stratcom', - 9 => 'javelin-util', - ), '44168bad' => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', @@ -1232,15 +1220,6 @@ return array( 2 => 'javelin-vector', 3 => 'javelin-dom', ), - '5a376f34' => array( - 0 => 'javelin-behavior', - 1 => 'javelin-typeahead-ondemand-source', - 2 => 'javelin-typeahead', - 3 => 'javelin-dom', - 4 => 'javelin-uri', - 5 => 'javelin-util', - 6 => 'javelin-stratcom', - ), '5bc2cb21' => array( 0 => 'javelin-behavior', 1 => 'javelin-stratcom', @@ -1690,6 +1669,18 @@ return array( 2 => 'javelin-util', 3 => 'phabricator-shaped-request', ), + 'c11bac49' => array( + 0 => 'javelin-install', + 1 => 'javelin-util', + 2 => 'javelin-dom', + 3 => 'javelin-typeahead', + 4 => 'javelin-tokenizer', + 5 => 'javelin-typeahead-preloaded-source', + 6 => 'javelin-typeahead-ondemand-source', + 7 => 'javelin-dom', + 8 => 'javelin-stratcom', + 9 => 'javelin-util', + ), 'c4569c05' => array( 0 => 'javelin-magical-init', 1 => 'javelin-install', @@ -1764,6 +1755,16 @@ return array( 2 => 'javelin-stratcom', 3 => 'javelin-dom', ), + 'd712ac5f' => array( + 0 => 'javelin-behavior', + 1 => 'javelin-typeahead-ondemand-source', + 2 => 'javelin-typeahead', + 3 => 'javelin-dom', + 4 => 'javelin-uri', + 5 => 'javelin-util', + 6 => 'javelin-stratcom', + 7 => 'phabricator-prefab', + ), 'd75709e6' => array( 0 => 'javelin-behavior', 1 => 'javelin-workflow', diff --git a/webroot/rsrc/js/core/Prefab.js b/webroot/rsrc/js/core/Prefab.js index f4e0bead01..7f87b8c7a8 100644 --- a/webroot/rsrc/js/core/Prefab.js +++ b/webroot/rsrc/js/core/Prefab.js @@ -31,6 +31,7 @@ JX.install('Prefab', { return select; }, + /** * Build a Phabricator tokenizer out of a configuration with application * sorting, datasource and placeholder rules. @@ -142,82 +143,9 @@ JX.install('Prefab', { }); }; - var render_icon = function(icon) { - return JX.$N( - 'span', - {className: 'phui-icon-view phui-font-fa ' + icon}); - }; - datasource.setSortHandler(JX.bind(datasource, sort_handler)); - - // Don't show any closed objects until the query is specific enough that - // it only selects closed objects. Specifically, if the result list had - // any open objects, remove all the closed objects from the list. - var filter_handler = function(value, list) { - // Look for any open result. - var has_open = false; - var ii; - for (ii = 0; ii < list.length; ii++) { - if (!list[ii].closed) { - has_open = true; - break; - } - } - - if (!has_open) { - // Everything is closed, so just use it as-is. - return list; - } - - // Otherwise, only display the open results. - var results = []; - for (ii = 0; ii < list.length; ii++) { - if (!list[ii].closed) { - results.push(list[ii]); - } - } - - return results; - }; - - datasource.setFilterHandler(filter_handler); - - datasource.setTransformer( - function(object) { - var closed = object[9]; - var closed_ui; - if (closed) { - closed_ui = JX.$N( - 'div', - {className: 'tokenizer-closed'}, - closed); - } - - var icon = object[8]; - var icon_ui; - if (icon) { - icon_ui = render_icon(icon); - } - - var display = JX.$N( - 'div', - {className: 'tokenizer-result'}, - [icon_ui, object[0], closed_ui]); - if (closed) { - JX.DOM.alterClass(display, 'tokenizer-result-closed', true); - } - - return { - name: object[0], - display: display, - uri: object[1], - id: object[2], - priority: object[3], - priorityType: object[7], - icon: icon, - closed: closed - }; - }); + datasource.setFilterHandler(JX.Prefab.filterClosedResults); + datasource.setTransformer(JX.Prefab.transformDatasourceResults); var typeahead = new JX.Typeahead( root, @@ -238,7 +166,7 @@ JX.install('Prefab', { return value; } - icon = render_icon(icon); + icon = JX.Prefab._renderIcon(icon); // TODO: Maybe we should render these closed tags in grey? Figure out // how we're going to use color. @@ -263,7 +191,89 @@ JX.install('Prefab', { return { tokenizer: tokenizer }; + }, + + /** + * Filter callback for tokenizers and typeaheads which filters out closed + * or disabled objects unless they are the only options. + */ + filterClosedResults: function(value, list) { + // Look for any open result. + var has_open = false; + var ii; + for (ii = 0; ii < list.length; ii++) { + if (!list[ii].closed) { + has_open = true; + break; + } + } + + if (!has_open) { + // Everything is closed, so just use it as-is. + return list; + } + + // Otherwise, only display the open results. + var results = []; + for (ii = 0; ii < list.length; ii++) { + if (!list[ii].closed) { + results.push(list[ii]); + } + } + + return results; + }, + + /** + * Transform results from a wire format into a usable format in a standard + * way. + */ + transformDatasourceResults: function(fields) { + var closed = fields[9]; + var closed_ui; + if (closed) { + closed_ui = JX.$N( + 'div', + {className: 'tokenizer-closed'}, + closed); + } + + var icon = fields[8]; + var icon_ui; + if (icon) { + icon_ui = JX.Prefab._renderIcon(icon); + } + + var display = JX.$N( + 'div', + {className: 'tokenizer-result'}, + [icon_ui, fields[4] || fields[0], closed_ui]); + if (closed) { + JX.DOM.alterClass(display, 'tokenizer-result-closed', true); + } + + return { + name: fields[0], + displayName: fields[4] || fields[0], + display: display, + uri: fields[1], + id: fields[2], + priority: fields[3], + priorityType: fields[7], + imageURI: fields[6], + icon: icon, + closed: closed, + type: fields[5], + sprite: fields[10] + }; + }, + + _renderIcon: function(icon) { + return JX.$N( + 'span', + {className: 'phui-icon-view phui-font-fa ' + icon}); } + } }); diff --git a/webroot/rsrc/js/core/behavior-search-typeahead.js b/webroot/rsrc/js/core/behavior-search-typeahead.js index 79b2401ff5..151f938195 100644 --- a/webroot/rsrc/js/core/behavior-search-typeahead.js +++ b/webroot/rsrc/js/core/behavior-search-typeahead.js @@ -7,6 +7,7 @@ * javelin-uri * javelin-util * javelin-stratcom + * phabricator-prefab */ JX.behavior('phabricator-search-typeahead', function(config) { @@ -14,31 +15,28 @@ JX.behavior('phabricator-search-typeahead', function(config) { var datasource = new JX.TypeaheadOnDemandSource(config.src); function transform(object) { + object = JX.Prefab.transformDatasourceResults(object); + var attr = { className: 'phabricator-main-search-typeahead-result' }; - if (object[6]) { - attr.style = {backgroundImage: 'url('+object[6]+')'}; + if (object.imageURI) { + attr.style = {backgroundImage: 'url('+object.imageURI+')'}; } var render = JX.$N( 'span', attr, [ - JX.$N('span', {className: object[10]}), - JX.$N('span', {className: 'result-name'}, object[4] || object[0]), - JX.$N('span', {className: 'result-type'}, object[5]) + JX.$N('span', {className: object.sprite}), + JX.$N('span', {className: 'result-name'}, object.displayName), + JX.$N('span', {className: 'result-type'}, object.type) ]); - return { - name: object[0], - display: render, - uri: object[1], - id: object[2], - priority: object[3], - type: object[7] - }; + object.display = render; + + return object; } datasource.setTransformer(transform); @@ -76,8 +74,8 @@ JX.behavior('phabricator-search-typeahead', function(config) { } list.sort(function(u, v) { - var u_type = type_priority[u.type] || 999; - var v_type = type_priority[v.type] || 999; + var u_type = type_priority[u.priorityType] || 999; + var v_type = type_priority[v.priorityType] || 999; if (u_type != v_type) { return u_type - v_type; @@ -120,6 +118,7 @@ JX.behavior('phabricator-search-typeahead', function(config) { }; datasource.setSortHandler(JX.bind(datasource, sort_handler)); + datasource.setFilterHandler(JX.Prefab.filterClosedResults); datasource.setMaximumResultCount(config.limit); var typeahead = new JX.Typeahead(JX.$(config.id), JX.$(config.input)); From 962e60c561e8378bb6f3fe0c8402dbf99d81d262 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:53:28 -0700 Subject: [PATCH 26/44] Retain focused node when redrawing tokenizer/typeahead results Summary: Ref T4420. Fixes T5473. Currently, when typeahead results get redrawn, you can lose your cursor position. A simple way to reproduce this is type "dif", select "Differential" using the arrow keys, then type "f". The selection will be lost. Instead: store the old selection, then look for an item with the same name in the new set and select it. In effect, this preserves any focus selection. Test Plan: - Typed "dif". - Typed "down arrow key" to select "Differential". - Typed "f". - "Differential" remained selected. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5473, T4420 Differential Revision: https://secure.phabricator.com/D9900 --- resources/celerity/map.php | 18 ++++++++-------- .../lib/control/typeahead/Typeahead.js | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index d4cc9e001f..68e907a27a 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -8,7 +8,7 @@ return array( 'names' => array( 'core.pkg.css' => 'c2c68e64', - 'core.pkg.js' => '0095fb2c', + 'core.pkg.js' => 'dc4959a8', 'darkconsole.pkg.js' => 'df001cab', 'differential.pkg.css' => '4a93db37', 'differential.pkg.js' => '7528cfc9', @@ -212,7 +212,7 @@ return array( 'rsrc/externals/javelin/lib/__tests__/behavior.js' => '1ea62783', 'rsrc/externals/javelin/lib/behavior.js' => '61cbc29a', 'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => 'a5b67173', - 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => '61f72a3d', + 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => 'e614d22b', 'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'aa93c7b0', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '503e17fd', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js' => '8b3fd187', @@ -683,7 +683,7 @@ return array( 'javelin-router' => '29274e2b', 'javelin-stratcom' => '8b0ad945', 'javelin-tokenizer' => 'a5b67173', - 'javelin-typeahead' => '61f72a3d', + 'javelin-typeahead' => 'e614d22b', 'javelin-typeahead-composite-source' => '503e17fd', 'javelin-typeahead-normalizer' => 'aa93c7b0', 'javelin-typeahead-ondemand-source' => '8b3fd187', @@ -1245,12 +1245,6 @@ return array( 0 => 'javelin-magical-init', 1 => 'javelin-util', ), - '61f72a3d' => array( - 0 => 'javelin-install', - 1 => 'javelin-dom', - 2 => 'javelin-vector', - 3 => 'javelin-util', - ), '6453c869' => array( 0 => 'javelin-install', 1 => 'javelin-dom', @@ -1836,6 +1830,12 @@ return array( 2 => 'javelin-view-visitor', 3 => 'javelin-util', ), + 'e614d22b' => array( + 0 => 'javelin-install', + 1 => 'javelin-dom', + 2 => 'javelin-vector', + 3 => 'javelin-util', + ), 'e9581f08' => array( 0 => 'javelin-behavior', 1 => 'javelin-stratcom', diff --git a/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js b/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js index 5d558efc2b..d8f8aa27bf 100644 --- a/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js +++ b/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js @@ -241,6 +241,15 @@ JX.install('Typeahead', { var obj = {show: results}; var e = this.invoke('show', obj); + // If the user has an element focused, store the value before we redraw. + // After we redraw, try to select the same element if it still exists in + // the list. This prevents redraws from disrupting keyboard element + // selection. + var old_focus = null; + if (this._focus >= 0 && this._display[this._focus]) { + old_focus = this._display[this._focus].name; + } + // Note that the results list may have been update by the "show" event // listener. Non-result node (e.g. divider or label) may have been // inserted. @@ -256,6 +265,18 @@ JX.install('Typeahead', { this._hardpoint.appendChild(this._root); } JX.DOM.show(this._root); + + // If we had a node focused before, look for a node with the same value + // and focus it. + if (old_focus !== null) { + for (var ii = 0; ii < this._display.length; ii++) { + if (this._display[ii].name == old_focus) { + this._focus = ii; + this._drawFocus(); + break; + } + } + } } else { this.hide(); JX.DOM.setContent(this._root, null); From 0e6756775c139c7174a9d09b242c4eb8eb29c975 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:55:43 -0700 Subject: [PATCH 27/44] Support placeholder text in Herald Summary: Ref T4420. We don't currently pass placeholder text properly, but should. Test Plan: Saw placeholder text in Herald. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9901 --- resources/celerity/map.php | 22 +++++++++---------- .../controller/HeraldRuleController.php | 7 +++++- .../js/application/herald/HeraldRuleEditor.js | 3 ++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 68e907a27a..aadb38f4ab 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -392,7 +392,7 @@ return array( 'rsrc/js/application/files/behavior-icon-composer.js' => '8ef9ab58', 'rsrc/js/application/files/behavior-launch-icon-composer.js' => '48086888', 'rsrc/js/application/harbormaster/behavior-reorder-steps.js' => 'b716477f', - 'rsrc/js/application/herald/HeraldRuleEditor.js' => '58e048fc', + 'rsrc/js/application/herald/HeraldRuleEditor.js' => '3fc2c8f2', 'rsrc/js/application/herald/PathTypeahead.js' => 'f7fc67ec', 'rsrc/js/application/herald/herald-rule-editor.js' => '7ebaeed3', 'rsrc/js/application/maniphest/behavior-batch-editor.js' => 'f588412e', @@ -543,7 +543,7 @@ return array( 'global-drag-and-drop-css' => '697324ad', 'harbormaster-css' => 'cec833b7', 'herald-css' => 'c544dd1c', - 'herald-rule-editor' => '58e048fc', + 'herald-rule-editor' => '3fc2c8f2', 'herald-test-css' => '778b008e', 'inline-comment-summary-css' => '8cfd34e8', 'javelin-aphlict' => '4a07e8e3', @@ -1103,6 +1103,15 @@ return array( 2 => 'javelin-stratcom', 3 => 'phabricator-tooltip', ), + '3fc2c8f2' => array( + 0 => 'multirow-row-manager', + 1 => 'javelin-install', + 2 => 'javelin-util', + 3 => 'javelin-dom', + 4 => 'javelin-stratcom', + 5 => 'javelin-json', + 6 => 'phabricator-prefab', + ), '40a6a403' => array( 0 => 'javelin-install', 1 => 'javelin-dom', @@ -1199,15 +1208,6 @@ return array( 2 => 'javelin-vector', 3 => 'javelin-dom', ), - '58e048fc' => array( - 0 => 'multirow-row-manager', - 1 => 'javelin-install', - 2 => 'javelin-util', - 3 => 'javelin-dom', - 4 => 'javelin-stratcom', - 5 => 'javelin-json', - 6 => 'phabricator-prefab', - ), '58f7803f' => array( 0 => 'javelin-behavior', 1 => 'javelin-aphlict', diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php index 75a5c297e2..83c91e5d07 100644 --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -601,7 +601,12 @@ final class HeraldRuleController extends HeraldController { 'userorproject' => new PhabricatorProjectOrUserDatasource(), ); - $sources = mpull($sources, 'getDatasourceURI'); + foreach ($sources as $key => $source) { + $sources[$key] = array( + 'uri' => $source->getDatasourceURI(), + 'placeholder' => $source->getPlaceholderText(), + ); + } return array( 'source' => $sources, diff --git a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js index 4bfe502af6..f9da34e0f6 100644 --- a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js +++ b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js @@ -283,7 +283,8 @@ JX.install('HeraldRuleEditor', { var tokenizerConfig = { root : template, - src : this._config.template.source[type], + src : this._config.template.source[type].uri, + placeholder: this._config.template.source[type].placeholder, icons : this._config.template.icons, username : this._config.username }; From 4135ba48b0b8db7b8674b5da41ba866b4579f495 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:56:20 -0700 Subject: [PATCH 28/44] Mostly modernize the policy control typeahead Summary: Ref T4420. This doesn't share all the code it really should, and renders a little odd. Make it more standard. (Icons aren't handled totally correctly but there's no usability impact and all that code should just get cleaned up.) Test Plan: Used custom policy typeahead, had a more standard experience. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9902 --- resources/celerity/map.php | 23 ++++++++----------- .../policy/behavior-policy-rule-editor.js | 18 ++++++--------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index aadb38f4ab..5b9539dd00 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -414,7 +414,7 @@ return array( 'rsrc/js/application/phortune/behavior-test-payment-form.js' => 'ab8d2723', 'rsrc/js/application/phortune/phortune-credit-card-form.js' => '2290aeef', 'rsrc/js/application/policy/behavior-policy-control.js' => 'f3fef818', - 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '0ea85aa3', + 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => 'fe9a552f', 'rsrc/js/application/ponder/behavior-votebox.js' => '4e9b766b', 'rsrc/js/application/projects/behavior-boards-dropdown.js' => '0ec56e1d', 'rsrc/js/application/projects/behavior-project-boards.js' => 'c6b95cbd', @@ -641,7 +641,7 @@ return array( 'javelin-behavior-phui-object-box-tabs' => 'a3e2244e', 'javelin-behavior-phui-timeline-dropdown-menu' => '4d94d9c3', 'javelin-behavior-policy-control' => 'f3fef818', - 'javelin-behavior-policy-rule-editor' => '0ea85aa3', + 'javelin-behavior-policy-rule-editor' => 'fe9a552f', 'javelin-behavior-ponder-votebox' => '4e9b766b', 'javelin-behavior-project-boards' => 'c6b95cbd', 'javelin-behavior-project-create' => '065227cc', @@ -899,17 +899,6 @@ return array( 3 => 'javelin-util', 4 => 'phabricator-notification-css', ), - '0ea85aa3' => array( - 0 => 'javelin-behavior', - 1 => 'multirow-row-manager', - 2 => 'javelin-dom', - 3 => 'javelin-util', - 4 => 'phabricator-prefab', - 5 => 'javelin-tokenizer', - 6 => 'javelin-typeahead', - 7 => 'javelin-typeahead-ondemand-source', - 8 => 'javelin-json', - ), '0ec56e1d' => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', @@ -1956,6 +1945,14 @@ return array( 2 => 'javelin-dom', 3 => 'javelin-typeahead-normalizer', ), + 'fe9a552f' => array( + 0 => 'javelin-behavior', + 1 => 'multirow-row-manager', + 2 => 'javelin-dom', + 3 => 'javelin-util', + 4 => 'phabricator-prefab', + 5 => 'javelin-json', + ), 42126667 => array( 0 => 'javelin-behavior', 1 => 'javelin-dom', diff --git a/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js b/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js index af3d382a99..3da2cdad5c 100644 --- a/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js +++ b/webroot/rsrc/js/application/policy/behavior-policy-rule-editor.js @@ -5,9 +5,6 @@ * javelin-dom * javelin-util * phabricator-prefab - * javelin-tokenizer - * javelin-typeahead - * javelin-typeahead-ondemand-source * javelin-json */ JX.behavior('policy-rule-editor', function(config) { @@ -124,15 +121,14 @@ JX.behavior('policy-rule-editor', function(config) { node = JX.$H(template.markup).getNode(); node.id = ''; - var datasource = new JX.TypeaheadOnDemandSource(template.uri); + var options = { + root: node, + src: template.uri, + placeholder: template.placeholder, + limit: template.limit + }; - var typeahead = new JX.Typeahead(node); - typeahead.setDatasource(datasource); - - var tokenizer = new JX.Tokenizer(node); - tokenizer.setLimit(template.limit); - tokenizer.setTypeahead(typeahead); - tokenizer.setPlaceholder(template.placeholder); + var tokenizer = JX.Prefab.buildTokenizer(options).tokenizer; tokenizer.start(); get_fn = function() { return JX.keys(tokenizer.getTokens()); }; From 45ea88cec48673303c1e23eacc3fcf8ad50091ff Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 15:56:39 -0700 Subject: [PATCH 29/44] Add more columns to typeahead wire format debugging view Summary: Fixes T4420. This isn't perfect but is one step less janky, at least. Test Plan: Viewed debugging view at `/typeahead/class/`, no unlabeled columns. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T4420 Differential Revision: https://secure.phabricator.com/D9903 --- ...orTypeaheadModularDatasourceController.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php index 98c0d40d88..f08538977d 100644 --- a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php +++ b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php @@ -86,14 +86,17 @@ final class PhabricatorTypeaheadModularDatasourceController $table = new AphrontTableView($content); $table->setHeaders( array( - 'Name', - 'URI', - 'PHID', - 'Priority', - 'Display Name', - 'Display Type', - 'Image URI', - 'Priority Type', + pht('Name'), + pht('URI'), + pht('PHID'), + pht('Priority'), + pht('Display Name'), + pht('Display Type'), + pht('Image URI'), + pht('Priority Type'), + pht('Icon'), + pht('Closed'), + pht('Sprite'), )); $result_box = id(new PHUIObjectBoxView()) From 41a8837f78dbe739c000ac0c2fda67d7e3b6a1fe Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 18 Jul 2014 09:01:46 +1000 Subject: [PATCH 30/44] Make HTTP errors returned from the Aphlict server more specific Summary: Ref T5651. Currently, the Aphlict server returns either `200 OKAY` or `400 Bad Request`. We could return more specific errors in some cases and this may assist with debugging. Test Plan: Sent myself a test notification at `/notification/status/` and saw the Aphlict server process the request (running in debug mode). Also poked around with `curl`: ``` > curl http://localhost:22281/ 405 Method Not Allowed > curl http://localhost:22281/ -d "" 400 Bad Request > curl http://localhost:22281/foobar/ 404 Not Found ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5651 Differential Revision: https://secure.phabricator.com/D9967 --- .../client/PhabricatorNotificationClient.php | 2 + support/aphlict/server/aphlict_server.js | 56 ++++++++++--------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/applications/notification/client/PhabricatorNotificationClient.php b/src/applications/notification/client/PhabricatorNotificationClient.php index f7d45316b4..dedbda6d70 100644 --- a/src/applications/notification/client/PhabricatorNotificationClient.php +++ b/src/applications/notification/client/PhabricatorNotificationClient.php @@ -40,6 +40,8 @@ final class PhabricatorNotificationClient { private static function postMessage(array $data) { $server_uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); + $server_uri = id(new PhutilURI($server_uri)) + ->setPath('/'); id(new HTTPSFuture($server_uri, json_encode($data))) ->setMethod('POST') diff --git a/support/aphlict/server/aphlict_server.js b/support/aphlict/server/aphlict_server.js index f0bc7b854c..f079a059bd 100644 --- a/support/aphlict/server/aphlict_server.js +++ b/support/aphlict/server/aphlict_server.js @@ -163,33 +163,39 @@ var start_time = new Date().getTime(); var receive_server = http.createServer(function(request, response) { // Publishing a notification. - if (request.method == 'POST') { - var body = ''; + if (request.url == '/') { + if (request.method == 'POST') { + var body = ''; - request.on('data', function(data) { - body += data; - }); + request.on('data', function(data) { + body += data; + }); - request.on('end', function() { - try { - var msg = JSON.parse(body); + request.on('end', function() { + try { + var msg = JSON.parse(body); - debug.log('notification: ' + JSON.stringify(msg)); - ++messages_in; - transmit(msg); + debug.log('notification: ' + JSON.stringify(msg)); + ++messages_in; + transmit(msg); - response.writeHead(200, {'Content-Type': 'text/plain'}); - } catch (err) { - debug.log( - '<%s> Bad Request! %s', - request.socket.remoteAddress, - err); - response.statusCode = 400; - response.write('400 Bad Request'); - } finally { - response.end(); - } - }); + response.writeHead(200, {'Content-Type': 'text/plain'}); + } catch (err) { + debug.log( + '<%s> Bad Request! %s', + request.socket.remoteAddress, + err); + response.statusCode = 400; + response.write('400 Bad Request\n'); + } finally { + response.end(); + } + }); + } else { + response.statusCode = 405; + response.write('405 Method Not Allowed\n'); + response.end(); + } } else if (request.url == '/status/') { request.on('data', function() { // We just ignore the request data, but newer versions of Node don't @@ -212,8 +218,8 @@ var receive_server = http.createServer(function(request, response) { response.end(); }); } else { - response.statusCode = 400; - response.write('400 Bad Request'); + response.statusCode = 404; + response.write('404 Not Found\n'); response.end(); } }).listen(config.admin, config.host); From f2fee5a84e62874ba6b252cb02203f6e4e7e88f9 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 18 Jul 2014 09:20:00 +1000 Subject: [PATCH 31/44] Return a HTTP 500 instead of a HTTP 400 if an internal error occurs in the Aphlict server Summary: Ref T5651. Only throw a HTTP 400 if the data is invalid (i.e. the request is bad). If something bad happens when trying to transmit the notification, throw a HTTP 500 instead. Test Plan: Eye-ball it. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5651 Differential Revision: https://secure.phabricator.com/D9968 --- support/aphlict/server/aphlict_server.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/support/aphlict/server/aphlict_server.js b/support/aphlict/server/aphlict_server.js index f079a059bd..f6dd53dbf9 100644 --- a/support/aphlict/server/aphlict_server.js +++ b/support/aphlict/server/aphlict_server.js @@ -177,9 +177,18 @@ var receive_server = http.createServer(function(request, response) { debug.log('notification: ' + JSON.stringify(msg)); ++messages_in; - transmit(msg); - response.writeHead(200, {'Content-Type': 'text/plain'}); + try { + transmit(msg); + response.writeHead(200, {'Content-Type': 'text/plain'}); + } catch (err) { + debug.log( + '<%s> Internal Server Error! %s', + request.socket.remoteAddress, + err); + response.statusCode = 500; + response.write('500 Internal Server Error\n'); + } } catch (err) { debug.log( '<%s> Bad Request! %s', From a115810912e7e42422543941b2e4a84c4d61b67c Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 16:35:54 -0700 Subject: [PATCH 32/44] Give projects a proper on-demand datasource Summary: Fixes T5614. Ref T4420. Other than the "users" datasource and a couple of others, many datasources ignore what the user typed and just return all results, then rely on the client to filter them. This works fine for rarely used ("legalpad documents") or always small ("task priorities", "applications") datasets, but is something we should graudally move away from as datasets get larger. Add a token table to projects, populate it, and use it to drive the datasource query. Additionally, expose it on the applicationsearch UI. Test Plan: - Ran migration. - Manually checked the table. - Searched for projects by name from ApplicationSearch. - Searched for projects by name from typeahead. - Manually checked the typeahead response. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5614, T4420 Differential Revision: https://secure.phabricator.com/D9896 --- .../sql/autopatches/20140711.pnames.1.sql | 7 +++ .../sql/autopatches/20140711.pnames.2.php | 11 +++++ .../people/storage/PhabricatorUser.php | 20 ++------ .../PhabricatorProjectTransactionEditor.php | 5 ++ .../project/query/PhabricatorProjectQuery.php | 33 +++++++++++-- .../query/PhabricatorProjectSearchEngine.php | 13 +++++ .../project/storage/PhabricatorProject.php | 49 +++++++++++++++++++ .../PhabricatorProjectDatasource.php | 19 ++++++- .../PhabricatorTypeaheadDatasource.php | 11 +++++ 9 files changed, 145 insertions(+), 23 deletions(-) create mode 100644 resources/sql/autopatches/20140711.pnames.1.sql create mode 100644 resources/sql/autopatches/20140711.pnames.2.php diff --git a/resources/sql/autopatches/20140711.pnames.1.sql b/resources/sql/autopatches/20140711.pnames.1.sql new file mode 100644 index 0000000000..9fce73a47e --- /dev/null +++ b/resources/sql/autopatches/20140711.pnames.1.sql @@ -0,0 +1,7 @@ +CREATE TABLE {$NAMESPACE}_project.project_datasourcetoken ( + id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + projectID INT UNSIGNED NOT NULL, + token VARCHAR(128) NOT NULL COLLATE utf8_general_ci, + UNIQUE KEY (token, projectID), + KEY (projectID) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/resources/sql/autopatches/20140711.pnames.2.php b/resources/sql/autopatches/20140711.pnames.2.php new file mode 100644 index 0000000000..ee3658384f --- /dev/null +++ b/resources/sql/autopatches/20140711.pnames.2.php @@ -0,0 +1,11 @@ +getName(); + echo "Updating project '{$name}'...\n"; + $project->updateDatasourceTokens(); +} + +echo "Done.\n"; diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index e12bef88f8..53a883106e 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -459,32 +459,18 @@ final class PhabricatorUser return $this; } - private static function tokenizeName($name) { - if (function_exists('mb_strtolower')) { - $name = mb_strtolower($name, 'UTF-8'); - } else { - $name = strtolower($name); - } - $name = trim($name); - if (!strlen($name)) { - return array(); - } - return preg_split('/\s+/', $name); - } - /** * Populate the nametoken table, which used to fetch typeahead results. When * a user types "linc", we want to match "Abraham Lincoln" from on-demand * typeahead sources. To do this, we need a separate table of name fragments. */ public function updateNameTokens() { - $tokens = array_merge( - self::tokenizeName($this->getRealName()), - self::tokenizeName($this->getUserName())); - $tokens = array_unique($tokens); $table = self::NAMETOKEN_TABLE; $conn_w = $this->establishConnection('w'); + $tokens = PhabricatorTypeaheadDatasource::tokenizeString( + $this->getUserName().' '.$this->getRealName()); + $sql = array(); foreach ($tokens as $token) { $sql[] = qsprintf( diff --git a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php index 386fb150d5..8fd66e77eb 100644 --- a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php +++ b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php @@ -125,6 +125,8 @@ final class PhabricatorProjectTransactionEditor ->setProjectPHID($object->getPHID()) ->save(); + $object->updateDatasourceTokens(); + // TODO -- delete all of the below once we sever automagical project // to phriction stuff if ($xaction->getOldValue() === null) { @@ -182,6 +184,9 @@ final class PhabricatorProjectTransactionEditor $rem_slug->delete(); } } + + $object->updateDatasourceTokens(); + return; case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY: diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php index d4dc86e4ce..9f15c2c0ec 100644 --- a/src/applications/project/query/PhabricatorProjectQuery.php +++ b/src/applications/project/query/PhabricatorProjectQuery.php @@ -9,6 +9,7 @@ final class PhabricatorProjectQuery private $slugs; private $phrictionSlugs; private $names; + private $datasourceQuery; private $status = 'status-any'; const STATUS_ANY = 'status-any'; @@ -57,6 +58,11 @@ final class PhabricatorProjectQuery return $this; } + public function withDatasourceQuery($string) { + $this->datasourceQuery = $string; + return $this; + } + public function needMembers($need_members) { $this->needMembers = $need_members; return $this; @@ -286,7 +292,7 @@ final class PhabricatorProjectQuery } private function buildGroupClause($conn_r) { - if ($this->memberPHIDs) { + if ($this->memberPHIDs || $this->datasourceQuery) { return 'GROUP BY p.id'; } else { return $this->buildApplicationSearchGroupClause($conn_r); @@ -296,7 +302,7 @@ final class PhabricatorProjectQuery private function buildJoinClause($conn_r) { $joins = array(); - if (!$this->needMembers) { + if (!$this->needMembers !== null) { $joins[] = qsprintf( $conn_r, 'LEFT JOIN %T vm ON vm.src = p.phid AND vm.type = %d AND vm.dst = %s', @@ -305,7 +311,7 @@ final class PhabricatorProjectQuery $this->getViewer()->getPHID()); } - if ($this->memberPHIDs) { + if ($this->memberPHIDs !== null) { $joins[] = qsprintf( $conn_r, 'JOIN %T e ON e.src = p.phid AND e.type = %d', @@ -313,13 +319,32 @@ final class PhabricatorProjectQuery PhabricatorEdgeConfig::TYPE_PROJ_MEMBER); } - if ($this->slugs) { + if ($this->slugs !== null) { $joins[] = qsprintf( $conn_r, 'JOIN %T slug on slug.projectPHID = p.phid', id(new PhabricatorProjectSlug())->getTableName()); } + if ($this->datasourceQuery !== null) { + $tokens = PhabricatorTypeaheadDatasource::tokenizeString( + $this->datasourceQuery); + if (!$tokens) { + throw new PhabricatorEmptyQueryException(); + } + + $likes = array(); + foreach ($tokens as $token) { + $likes[] = qsprintf($conn_r, 'token.token LIKE %>', $token); + } + + $joins[] = qsprintf( + $conn_r, + 'JOIN %T token ON token.projectID = p.id AND (%Q)', + PhabricatorProject::TABLE_DATASOURCE_TOKEN, + '('.implode(') OR (', $likes).')'); + } + $joins[] = $this->buildApplicationSearchJoinClause($conn_r); return implode(' ', $joins); diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index 0122e17d0b..7120682cfb 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -21,7 +21,9 @@ final class PhabricatorProjectSearchEngine $saved->setParameter( 'memberPHIDs', $this->readUsersFromRequest($request, 'members')); + $saved->setParameter('status', $request->getStr('status')); + $saved->setParameter('name', $request->getStr('name')); $this->readCustomFieldsFromRequest($request, $saved); @@ -43,6 +45,11 @@ final class PhabricatorProjectSearchEngine $query->withStatus($status); } + $name = $saved->getParameter('name'); + if (strlen($name)) { + $query->withDatasourceQuery($name); + } + $this->applyCustomFieldsToQuery($query, $saved); return $query; @@ -59,8 +66,14 @@ final class PhabricatorProjectSearchEngine ->execute(); $status = $saved->getParameter('status'); + $name = $saved->getParameter('name'); $form + ->appendChild( + id(new AphrontFormTextControl()) + ->setName('name') + ->setLabel(pht('Name')) + ->setValue($name)) ->appendChild( id(new AphrontFormTokenizerControl()) ->setDatasource(new PhabricatorPeopleDatasource()) diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php index 720c542392..fbcf331509 100644 --- a/src/applications/project/storage/PhabricatorProject.php +++ b/src/applications/project/storage/PhabricatorProject.php @@ -32,6 +32,8 @@ final class PhabricatorProject extends PhabricatorProjectDAO const DEFAULT_ICON = 'fa-briefcase'; const DEFAULT_COLOR = 'blue'; + const TABLE_DATASOURCE_TOKEN = 'project_datasourcetoken'; + public static function initializeNewProject(PhabricatorUser $actor) { return id(new PhabricatorProject()) ->setName('') @@ -219,6 +221,53 @@ final class PhabricatorProject extends PhabricatorProjectDAO return $this->color; } + public function save() { + $this->openTransaction(); + $result = parent::save(); + $this->updateDatasourceTokens(); + $this->saveTransaction(); + + return $result; + } + + public function updateDatasourceTokens() { + $table = self::TABLE_DATASOURCE_TOKEN; + $conn_w = $this->establishConnection('w'); + $id = $this->getID(); + + $slugs = queryfx_all( + $conn_w, + 'SELECT * FROM %T WHERE projectPHID = %s', + id(new PhabricatorProjectSlug())->getTableName(), + $this->getPHID()); + + $all_strings = ipull($slugs, 'slug'); + $all_strings[] = $this->getName(); + $all_strings = implode(' ', $all_strings); + + $tokens = PhabricatorTypeaheadDatasource::tokenizeString($all_strings); + + $sql = array(); + foreach ($tokens as $token) { + $sql[] = qsprintf($conn_w, '(%d, %s)', $id, $token); + } + + $this->openTransaction(); + queryfx( + $conn_w, + 'DELETE FROM %T WHERE projectID = %d', + $table, + $id); + + foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) { + queryfx( + $conn_w, + 'INSERT INTO %T (projectID, token) VALUES %Q', + $table, + $chunk); + } + $this->saveTransaction(); + } /* -( PhabricatorSubscribableInterface )----------------------------------- */ diff --git a/src/applications/project/typeahead/PhabricatorProjectDatasource.php b/src/applications/project/typeahead/PhabricatorProjectDatasource.php index f9bba5c33f..40ffc28724 100644 --- a/src/applications/project/typeahead/PhabricatorProjectDatasource.php +++ b/src/applications/project/typeahead/PhabricatorProjectDatasource.php @@ -13,22 +13,37 @@ final class PhabricatorProjectDatasource public function loadResults() { $viewer = $this->getViewer(); + $raw_query = $this->getRawQuery(); - $results = array(); + // Allow users to type "#qa" or "qa" to find "Quality Assurance". + $raw_query = ltrim($raw_query, '#'); + + if (!strlen($raw_query)) { + return array(); + } $projs = id(new PhabricatorProjectQuery()) ->setViewer($viewer) ->needImages(true) + ->needSlugs(true) + ->withDatasourceQuery($raw_query) ->execute(); + + $results = array(); foreach ($projs as $proj) { $closed = null; if ($proj->isArchived()) { $closed = pht('Archived'); } + $all_strings = mpull($proj->getSlugs(), 'getSlug'); + $all_strings[] = $proj->getName(); + $all_strings = implode(' ', $all_strings); + $proj_result = id(new PhabricatorTypeaheadResult()) - ->setName($proj->getName()) + ->setName($all_strings) + ->setDisplayName($proj->getName()) ->setDisplayType('Project') ->setURI('/tag/'.$proj->getPrimarySlug().'/') ->setPHID($proj->getPHID()) diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php index 7ec636dda0..7ce5f5ab33 100644 --- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php +++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php @@ -51,4 +51,15 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject { abstract public function getDatasourceApplicationClass(); abstract public function loadResults(); + public static function tokenizeString($string) { + $string = phutil_utf8_strtolower($string); + $string = trim($string); + if (!strlen($string)) { + return array(); + } + + $tokens = preg_split('/\s+/', $string); + return array_unique($tokens); + } + } From bd3c239d5aada68a31db5742bbb8ec099074a561 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 17:30:41 -0700 Subject: [PATCH 33/44] Remove a stray `setActor()` on EdgeEditor Summary: These got removed recently but I missed one callsite. Test Plan: Used `git grep` to double check all other callsites. Reviewers: joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D9973 --- .../editor/PhabricatorApplicationTransactionEditor.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index c7426e2269..44a9dc48d5 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -2342,8 +2342,7 @@ abstract class PhabricatorApplicationTransactionEditor return; } - $editor = id(new PhabricatorEdgeEditor()) - ->setActor($this->getActor()); + $editor = new PhabricatorEdgeEditor(); $src = $object->getPHID(); $type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE; From 570a78d42af78cf1aac657c64cf08c5cc75f92c2 Mon Sep 17 00:00:00 2001 From: Tal Shiri Date: Thu, 17 Jul 2014 18:32:44 -0700 Subject: [PATCH 34/44] don't add email addresses to CC if they are already in TO Summary: Some mailers remove the duplicate entries themselves, but some (Mailgun) don't. This affects installations with metamta.one-mail-per-recipient set to false, and will cause - ugly looking "to" entries. Gmail, for example, collapses to+cc entries to one list, so you get something that looks like "to: me me john" - It sometimes causes duplicate delivery of the same message when used in conjuction with Google Groups. I suspect that their message de-dup mechanism is confused by it (I fuzzed it directly with Mailgun, and saw the same message delivered twice - once directly through mailgun, and bounced again through Google Groups). This doesn't happen when the entries are not duplicated. Test Plan: Created some tasks. Added subscribers. Things seem to work reasonably well. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9978 --- src/applications/metamta/storage/PhabricatorMetaMTAMail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index 545ad9c822..e5445b0abf 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -606,7 +606,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { } $add_to = array_unique($add_to); - $add_cc = array_unique($add_cc); + $add_cc = array_diff(array_unique($add_cc), $add_to); $mailer->addTos($add_to); if ($add_cc) { From 48f6189f32263b303125de11478eab489e75cf11 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 18 Jul 2014 11:35:22 +1000 Subject: [PATCH 35/44] Allow mailing lists to be permanently deleted Summary: Allow `PhabricatorMetaMTAMailingList` to be permanently deleted with `./bin/remove destroy`. Test Plan: ``` ./bin/remove destroy PHID-MLST-nseux3r55escj573shsf IMPORTANT: OBJECTS WILL BE PERMANENTLY DESTROYED! There is no way to undo this operation or ever retrieve this data. These 1 object(s) will be completely destroyed forever: - PHID-MLST-nseux3r55escj573shsf (PhabricatorMetaMTAMailingList) Are you absolutely certain you want to destroy these 1 object(s)? [y/N] y Destroying objects... Destroying PhabricatorMetaMTAMailingList PHID-MLST-nseux3r55escj573shsf... Permanently destroyed 1 object(s). ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9979 --- .../storage/PhabricatorMetaMTAMailingList.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php b/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php index b24ca55185..578c3cf744 100644 --- a/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php +++ b/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php @@ -1,7 +1,9 @@ openTransaction(); + $this->delete(); + $this->saveTransaction(); + } + } From 17afcdcf95329dda2ee3e7acec2ce3e8047624fb Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Jul 2014 18:37:09 -0700 Subject: [PATCH 36/44] Explicitly degrade edge editing for commit/task edges until T4896 Summary: Commits don't support `PhabricatorApplicationTransactionInterface` yet, so the "Edit Maniphest Tasks" dialog from the commit UI currently bombs. Hard-code it to do the correct writes in a low-level way. After T4896 we can remove this and do `ApplicationTransaction` stuff. Test Plan: Used the "Edit Maniphest Tasks" UI from Diffusion. Reviewers: joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D9975 --- .../PhabricatorSearchAttachController.php | 84 +++++++++++++------ 1 file changed, 59 insertions(+), 25 deletions(-) diff --git a/src/applications/search/controller/PhabricatorSearchAttachController.php b/src/applications/search/controller/PhabricatorSearchAttachController.php index b6519a3e0b..bd0d575207 100644 --- a/src/applications/search/controller/PhabricatorSearchAttachController.php +++ b/src/applications/search/controller/PhabricatorSearchAttachController.php @@ -57,33 +57,67 @@ final class PhabricatorSearchAttachController $phids = array_values($phids); if ($edge_type) { - if (!$object instanceof PhabricatorApplicationTransactionInterface) { - throw new Exception( - pht( - 'Expected object ("%s") to implement interface "%s".', - get_class($object), - 'PhabricatorApplicationTransactionInterface')); + if ($object instanceof PhabricatorRepositoryCommit) { + // TODO: Remove this entire branch of special cased grossness + // after T4896. + + $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( + $this->phid, + $edge_type); + $add_phids = $phids; + $rem_phids = array_diff($old_phids, $add_phids); + + // Doing this correctly (in a way that writes edge transactions) would + // be a huge mess and we don't get the commit half of the transaction + // anyway until T4896, so just write the edges themselves and skip + // the transactions for now. + + $editor = new PhabricatorEdgeEditor(); + foreach ($add_phids as $phid) { + $editor->addEdge( + $object->getPHID(), + DiffusionCommitHasTaskEdgeType::EDGECONST, + $phid); + } + + foreach ($rem_phids as $phid) { + $editor->removeEdge( + $object->getPHID(), + DiffusionCommitHasTaskEdgeType::EDGECONST, + $phid); + } + + $editor->save(); + + } else { + if (!$object instanceof PhabricatorApplicationTransactionInterface) { + throw new Exception( + pht( + 'Expected object ("%s") to implement interface "%s".', + get_class($object), + 'PhabricatorApplicationTransactionInterface')); + } + + $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( + $this->phid, + $edge_type); + $add_phids = $phids; + $rem_phids = array_diff($old_phids, $add_phids); + + $txn_editor = $object->getApplicationTransactionEditor() + ->setActor($user) + ->setContentSourceFromRequest($request); + $txn_template = $object->getApplicationTransactionTemplate() + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $edge_type) + ->setNewValue(array( + '+' => array_fuse($add_phids), + '-' => array_fuse($rem_phids))); + $txn_editor->applyTransactions( + $object->getApplicationTransactionObject(), + array($txn_template)); } - $old_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( - $this->phid, - $edge_type); - $add_phids = $phids; - $rem_phids = array_diff($old_phids, $add_phids); - - $txn_editor = $object->getApplicationTransactionEditor() - ->setActor($user) - ->setContentSourceFromRequest($request); - $txn_template = $object->getApplicationTransactionTemplate() - ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) - ->setMetadataValue('edge:type', $edge_type) - ->setNewValue(array( - '+' => array_fuse($add_phids), - '-' => array_fuse($rem_phids))); - $txn_editor->applyTransactions( - $object->getApplicationTransactionObject(), - array($txn_template)); - return id(new AphrontReloadResponse())->setURI($handle->getURI()); } else { return $this->performMerge($object, $handle, $phids); From 63ce0e66c926222a5a805d5199c8ea98cc4bc129 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 18 Jul 2014 11:38:09 +1000 Subject: [PATCH 37/44] Allow Phriction documents to be permanently deleted Summary: Allow `PhrictionDocument` to be permanently deleted with `./bin/remove destroy`. Test Plan: Deleted a Phriction document with `./bin/remove` and verified that the database was in the expected state. ``` > ./bin/remove destroy PHID-WIKI-auj57rauigvcqvv5feh6 IMPORTANT: OBJECTS WILL BE PERMANENTLY DESTROYED! There is no way to undo this operation or ever retrieve this data. These 1 object(s) will be completely destroyed forever: - PHID-WIKI-auj57rauigvcqvv5feh6 (PhrictionDocument) Are you absolutely certain you want to destroy these 1 object(s)? [y/N] y Destroying objects... Destroying PhrictionDocument PHID-WIKI-auj57rauigvcqvv5feh6... Permanently destroyed 1 object(s). ``` Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D9976 --- .../phriction/storage/PhrictionDocument.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php index 8c5b5d58bc..07a3d5ec0f 100644 --- a/src/applications/phriction/storage/PhrictionDocument.php +++ b/src/applications/phriction/storage/PhrictionDocument.php @@ -5,7 +5,8 @@ final class PhrictionDocument extends PhrictionDAO PhabricatorPolicyInterface, PhabricatorSubscribableInterface, PhabricatorFlaggableInterface, - PhabricatorTokenReceiverInterface { + PhabricatorTokenReceiverInterface, + PhabricatorDestructableInterface { protected $slug; protected $depth; @@ -180,4 +181,26 @@ final class PhrictionDocument extends PhrictionDAO public function getUsersToNotifyOfTokenGiven() { return PhabricatorSubscribersQuery::loadSubscribersForPHID($this->phid); } + + +/* -( PhabricatorDestructableInterface )----------------------------------- */ + + + public function destroyObjectPermanently( + PhabricatorDestructionEngine $engine) { + + $this->openTransaction(); + + $this->delete(); + + $contents = id(new PhrictionContent())->loadAllWhere( + 'documentID = %d', + $this->getID()); + foreach ($contents as $content) { + $content->delete(); + } + + $this->saveTransaction(); + } + } From af214ecb657902de8dd4199ea493295a92115b70 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 21 Jul 2014 06:44:27 -0700 Subject: [PATCH 38/44] Fix rendering of project slugs in tokenizer UI Summary: Fixes T5659. When building a token after a user selection, we currently use the `value` as the token text, but sometimes that's an internal name which doesn't make much sense to users. For projects, it is now "sluga slugb Proper Display Name". If available, use `displayName` instead. Test Plan: Typed some projects into a tokenizer, got display names only. Reviewers: chad, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5659 Differential Revision: https://secure.phabricator.com/D9996 --- resources/celerity/map.php | 30 +++++++++++++++--------------- src/__phutil_library_map__.php | 1 + webroot/rsrc/js/core/Prefab.js | 15 ++++++++------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 5b9539dd00..f0e0f31fe6 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -8,7 +8,7 @@ return array( 'names' => array( 'core.pkg.css' => 'c2c68e64', - 'core.pkg.js' => 'dc4959a8', + 'core.pkg.js' => 'ba6a742f', 'darkconsole.pkg.js' => 'df001cab', 'differential.pkg.css' => '4a93db37', 'differential.pkg.js' => '7528cfc9', @@ -450,7 +450,7 @@ return array( 'rsrc/js/core/KeyboardShortcutManager.js' => 'ad7a69ca', 'rsrc/js/core/MultirowRowManager.js' => '41e47dea', 'rsrc/js/core/Notification.js' => '0c6946e7', - 'rsrc/js/core/Prefab.js' => 'c11bac49', + 'rsrc/js/core/Prefab.js' => 'bbae734c', 'rsrc/js/core/ShapedRequest.js' => '7cbe244b', 'rsrc/js/core/TextAreaUtils.js' => 'b3ec3cfc', 'rsrc/js/core/ToolTip.js' => '3915d490', @@ -737,7 +737,7 @@ return array( 'phabricator-notification-menu-css' => '8ae4a008', 'phabricator-object-selector-css' => '029a133d', 'phabricator-phtize' => 'd254d646', - 'phabricator-prefab' => 'c11bac49', + 'phabricator-prefab' => 'bbae734c', 'phabricator-profile-css' => 'b459416e', 'phabricator-remarkup-css' => 'ad4c0676', 'phabricator-search-results-css' => 'f240504c', @@ -1626,6 +1626,18 @@ return array( 1 => 'javelin-stratcom', 2 => 'javelin-dom', ), + 'bbae734c' => array( + 0 => 'javelin-install', + 1 => 'javelin-util', + 2 => 'javelin-dom', + 3 => 'javelin-typeahead', + 4 => 'javelin-tokenizer', + 5 => 'javelin-typeahead-preloaded-source', + 6 => 'javelin-typeahead-ondemand-source', + 7 => 'javelin-dom', + 8 => 'javelin-stratcom', + 9 => 'javelin-util', + ), 'bd4c8dca' => array( 0 => 'javelin-install', 1 => 'javelin-util', @@ -1652,18 +1664,6 @@ return array( 2 => 'javelin-util', 3 => 'phabricator-shaped-request', ), - 'c11bac49' => array( - 0 => 'javelin-install', - 1 => 'javelin-util', - 2 => 'javelin-dom', - 3 => 'javelin-typeahead', - 4 => 'javelin-tokenizer', - 5 => 'javelin-typeahead-preloaded-source', - 6 => 'javelin-typeahead-ondemand-source', - 7 => 'javelin-dom', - 8 => 'javelin-stratcom', - 9 => 'javelin-util', - ), 'c4569c05' => array( 0 => 'javelin-magical-init', 1 => 'javelin-install', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 86ff4fc8cc..5fdf42a6fc 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -4610,6 +4610,7 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAMailingList' => array( 0 => 'PhabricatorMetaMTADAO', 1 => 'PhabricatorPolicyInterface', + 2 => 'PhabricatorDestructableInterface', ), 'PhabricatorMetaMTAMemberQuery' => 'PhabricatorQuery', 'PhabricatorMetaMTAPermanentFailureException' => 'Exception', diff --git a/webroot/rsrc/js/core/Prefab.js b/webroot/rsrc/js/core/Prefab.js index 7f87b8c7a8..0cf2b5b8b3 100644 --- a/webroot/rsrc/js/core/Prefab.js +++ b/webroot/rsrc/js/core/Prefab.js @@ -155,19 +155,20 @@ JX.install('Prefab', { var tokenizer = new JX.Tokenizer(root); tokenizer.setTypeahead(typeahead); tokenizer.setRenderTokenCallback(function(value, key) { - var icon = datasource.getResult(key); - if (icon) { - icon = icon.icon; + var result = datasource.getResult(key); + + var icon; + if (result) { + icon = result.icon; + value = result.displayName; } else { icon = config.icons[key]; } - if (!icon) { - return value; + if (icon) { + icon = JX.Prefab._renderIcon(icon); } - icon = JX.Prefab._renderIcon(icon); - // TODO: Maybe we should render these closed tags in grey? Figure out // how we're going to use color. From 9d64beeaa345cddc4972015d2719d9aa33ecc01f Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 21 Jul 2014 06:44:35 -0700 Subject: [PATCH 39/44] Namespace `dateCreated` in Maniphest query construction Summary: Fixes T5661. We may now pick up a conflicting `dateCreated` field from an edge table join. Test Plan: Ran a project + dateCreated filtering query, no longer got an exception. Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T5661 Differential Revision: https://secure.phabricator.com/D9997 --- src/applications/maniphest/query/ManiphestTaskQuery.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php index 5c1d17bc8f..90eb3a8a14 100644 --- a/src/applications/maniphest/query/ManiphestTaskQuery.php +++ b/src/applications/maniphest/query/ManiphestTaskQuery.php @@ -206,28 +206,28 @@ final class ManiphestTaskQuery extends PhabricatorCursorPagedPolicyAwareQuery { if ($this->dateCreatedAfter) { $where[] = qsprintf( $conn, - 'dateCreated >= %d', + 'task.dateCreated >= %d', $this->dateCreatedAfter); } if ($this->dateCreatedBefore) { $where[] = qsprintf( $conn, - 'dateCreated <= %d', + 'task.dateCreated <= %d', $this->dateCreatedBefore); } if ($this->dateModifiedAfter) { $where[] = qsprintf( $conn, - 'dateModified >= %d', + 'task.dateModified >= %d', $this->dateModifiedAfter); } if ($this->dateModifiedBefore) { $where[] = qsprintf( $conn, - 'dateModified <= %d', + 'task.dateModified <= %d', $this->dateModifiedBefore); } From 76ed7d1a02c99ded33decbc542d4576bc19ef381 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Mon, 21 Jul 2014 23:59:22 +1000 Subject: [PATCH 40/44] Rename `PhabricatorDestructableInterface` interface Summary: Ref T5655. The `PhabricatorDestructibleInterface` interface is misspelled as `PhabricatorDestructableInterface`. Fix the spelling mistake. Test Plan: `grep`. Seeing as this interface is fairly recent, I don't expect that this would cause any widespread breakages. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5655 Differential Revision: https://secure.phabricator.com/D9988 --- src/__phutil_library_map__.php | 609 +++++++++--------- .../differential/storage/DifferentialDiff.php | 4 +- .../storage/DifferentialRevision.php | 4 +- .../herald/storage/HeraldRule.php | 4 +- .../legalpad/storage/LegalpadDocument.php | 4 +- .../storage/PhabricatorMetaMTAMailingList.php | 4 +- .../maniphest/storage/ManiphestTask.php | 4 +- .../people/storage/PhabricatorUser.php | 4 +- .../pholio/storage/PholioMock.php | 4 +- .../phriction/storage/PhrictionDocument.php | 4 +- .../project/storage/PhabricatorProject.php | 4 +- .../storage/PhabricatorProjectColumn.php | 7 +- .../storage/PhabricatorRepository.php | 4 +- .../PhabricatorRepositoryArcanistProject.php | 7 +- .../engine/PhabricatorDestructionEngine.php | 2 +- ...p => PhabricatorDestructibleInterface.php} | 2 +- ...PhabricatorSystemRemoveDestroyWorkflow.php | 4 +- .../PhabricatorApplicationTransaction.php | 4 +- ...abricatorApplicationTransactionComment.php | 4 +- 19 files changed, 343 insertions(+), 340 deletions(-) rename src/applications/system/interface/{PhabricatorDestructableInterface.php => PhabricatorDestructibleInterface.php} (89%) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 5fdf42a6fc..bd539556ec 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1549,7 +1549,7 @@ phutil_register_library_map(array( 'PhabricatorDebugController' => 'applications/system/controller/PhabricatorDebugController.php', 'PhabricatorDefaultFileStorageEngineSelector' => 'applications/files/engineselector/PhabricatorDefaultFileStorageEngineSelector.php', 'PhabricatorDefaultSearchEngineSelector' => 'applications/search/selector/PhabricatorDefaultSearchEngineSelector.php', - 'PhabricatorDestructableInterface' => 'applications/system/interface/PhabricatorDestructableInterface.php', + 'PhabricatorDestructibleInterface' => 'applications/system/interface/PhabricatorDestructibleInterface.php', 'PhabricatorDestructionEngine' => 'applications/system/engine/PhabricatorDestructionEngine.php', 'PhabricatorDeveloperConfigOptions' => 'applications/config/option/PhabricatorDeveloperConfigOptions.php', 'PhabricatorDifferenceEngine' => 'infrastructure/diff/PhabricatorDifferenceEngine.php', @@ -2819,8 +2819,8 @@ phutil_register_library_map(array( 'AphrontTypeaheadTemplateView' => 'AphrontView', 'AphrontUsageException' => 'AphrontException', 'AphrontView' => array( - 0 => 'Phobject', - 1 => 'PhutilSafeHTMLProducerInterface', + 'Phobject', + 'PhutilSafeHTMLProducerInterface', ), 'AphrontWebpageResponse' => 'AphrontHTMLResponse', 'AuditActionMenuEventListener' => 'PhabricatorEventListener', @@ -2836,8 +2836,8 @@ phutil_register_library_map(array( 'CelerityResourceTransformerTestCase' => 'PhabricatorTestCase', 'CelerityResourcesOnDisk' => 'CelerityPhysicalResources', 'ConduitAPIMethod' => array( - 0 => 'Phobject', - 1 => 'PhabricatorPolicyInterface', + 'Phobject', + 'PhabricatorPolicyInterface', ), 'ConduitAPI_arcanist_Method' => 'ConduitAPIMethod', 'ConduitAPI_arcanist_projectinfo_Method' => 'ConduitAPI_arcanist_Method', @@ -3019,8 +3019,8 @@ phutil_register_library_map(array( 'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler', 'ConpherenceSettings' => 'ConpherenceConstants', 'ConpherenceThread' => array( - 0 => 'ConpherenceDAO', - 1 => 'PhabricatorPolicyInterface', + 'ConpherenceDAO', + 'PhabricatorPolicyInterface', ), 'ConpherenceThreadListView' => 'AphrontView', 'ConpherenceThreadMailReceiver' => 'PhabricatorObjectMailReceiver', @@ -3057,8 +3057,8 @@ phutil_register_library_map(array( 'DifferentialCapabilityDefaultView' => 'PhabricatorPolicyCapability', 'DifferentialChangesSinceLastUpdateField' => 'DifferentialCustomField', 'DifferentialChangeset' => array( - 0 => 'DifferentialDAO', - 1 => 'PhabricatorPolicyInterface', + 'DifferentialDAO', + 'PhabricatorPolicyInterface', ), 'DifferentialChangesetDetailView' => 'AphrontView', 'DifferentialChangesetHTMLRenderer' => 'DifferentialChangesetRenderer', @@ -3090,11 +3090,11 @@ phutil_register_library_map(array( 'DifferentialDependenciesField' => 'DifferentialCustomField', 'DifferentialDependsOnField' => 'DifferentialCustomField', 'DifferentialDiff' => array( - 0 => 'DifferentialDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'HarbormasterBuildableInterface', - 3 => 'PhabricatorApplicationTransactionInterface', - 4 => 'PhabricatorDestructableInterface', + 'DifferentialDAO', + 'PhabricatorPolicyInterface', + 'HarbormasterBuildableInterface', + 'PhabricatorApplicationTransactionInterface', + 'PhabricatorDestructibleInterface', ), 'DifferentialDiffCreateController' => 'DifferentialController', 'DifferentialDiffProperty' => 'DifferentialDAO', @@ -3111,8 +3111,8 @@ phutil_register_library_map(array( 'DifferentialHostField' => 'DifferentialCustomField', 'DifferentialHovercardEventListener' => 'PhabricatorEventListener', 'DifferentialHunk' => array( - 0 => 'DifferentialDAO', - 1 => 'PhabricatorPolicyInterface', + 'DifferentialDAO', + 'PhabricatorPolicyInterface', ), 'DifferentialHunkLegacy' => 'DifferentialHunk', 'DifferentialHunkModern' => 'DifferentialHunk', @@ -3153,17 +3153,17 @@ phutil_register_library_map(array( 'DifferentialReviewersField' => 'DifferentialCoreCustomField', 'DifferentialReviewersView' => 'AphrontView', 'DifferentialRevision' => array( - 0 => 'DifferentialDAO', - 1 => 'PhabricatorTokenReceiverInterface', - 2 => 'PhabricatorPolicyInterface', - 3 => 'PhabricatorFlaggableInterface', - 4 => 'PhrequentTrackableInterface', - 5 => 'HarbormasterBuildableInterface', - 6 => 'PhabricatorSubscribableInterface', - 7 => 'PhabricatorCustomFieldInterface', - 8 => 'PhabricatorApplicationTransactionInterface', - 9 => 'PhabricatorDestructableInterface', - 10 => 'PhabricatorProjectInterface', + 'DifferentialDAO', + 'PhabricatorTokenReceiverInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorFlaggableInterface', + 'PhrequentTrackableInterface', + 'HarbormasterBuildableInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorCustomFieldInterface', + 'PhabricatorApplicationTransactionInterface', + 'PhabricatorDestructibleInterface', + 'PhabricatorProjectInterface', ), 'DifferentialRevisionDetailView' => 'AphrontView', 'DifferentialRevisionEditController' => 'DifferentialController', @@ -3329,14 +3329,14 @@ phutil_register_library_map(array( 'DivinerGenerateWorkflow' => 'DivinerWorkflow', 'DivinerLiveAtom' => 'DivinerDAO', 'DivinerLiveBook' => array( - 0 => 'DivinerDAO', - 1 => 'PhabricatorPolicyInterface', + 'DivinerDAO', + 'PhabricatorPolicyInterface', ), 'DivinerLivePublisher' => 'DivinerPublisher', 'DivinerLiveSymbol' => array( - 0 => 'DivinerDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorMarkupInterface', + 'DivinerDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorMarkupInterface', ), 'DivinerMainController' => 'DivinerController', 'DivinerPHIDTypeAtom' => 'PhabricatorPHIDType', @@ -3355,8 +3355,8 @@ phutil_register_library_map(array( 'DoorkeeperBridgeJIRATestCase' => 'PhabricatorTestCase', 'DoorkeeperDAO' => 'PhabricatorLiskDAO', 'DoorkeeperExternalObject' => array( - 0 => 'DoorkeeperDAO', - 1 => 'PhabricatorPolicyInterface', + 'DoorkeeperDAO', + 'PhabricatorPolicyInterface', ), 'DoorkeeperExternalObjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'DoorkeeperFeedWorker' => 'FeedPushWorker', @@ -3373,8 +3373,8 @@ phutil_register_library_map(array( 'DrydockAllocatorWorker' => 'PhabricatorWorker', 'DrydockApacheWebrootInterface' => 'DrydockWebrootInterface', 'DrydockBlueprint' => array( - 0 => 'DrydockDAO', - 1 => 'PhabricatorPolicyInterface', + 'DrydockDAO', + 'PhabricatorPolicyInterface', ), 'DrydockBlueprintController' => 'DrydockController', 'DrydockBlueprintCreateController' => 'DrydockBlueprintController', @@ -3395,8 +3395,8 @@ phutil_register_library_map(array( 'DrydockDAO' => 'PhabricatorLiskDAO', 'DrydockFilesystemInterface' => 'DrydockInterface', 'DrydockLease' => array( - 0 => 'DrydockDAO', - 1 => 'PhabricatorPolicyInterface', + 'DrydockDAO', + 'PhabricatorPolicyInterface', ), 'DrydockLeaseController' => 'DrydockController', 'DrydockLeaseListController' => 'DrydockLeaseController', @@ -3409,8 +3409,8 @@ phutil_register_library_map(array( 'DrydockLocalCommandInterface' => 'DrydockCommandInterface', 'DrydockLocalHostBlueprintImplementation' => 'DrydockBlueprintImplementation', 'DrydockLog' => array( - 0 => 'DrydockDAO', - 1 => 'PhabricatorPolicyInterface', + 'DrydockDAO', + 'PhabricatorPolicyInterface', ), 'DrydockLogController' => 'DrydockController', 'DrydockLogListController' => 'DrydockLogController', @@ -3428,8 +3428,8 @@ phutil_register_library_map(array( 'DrydockPreallocatedHostBlueprintImplementation' => 'DrydockBlueprintImplementation', 'DrydockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'DrydockResource' => array( - 0 => 'DrydockDAO', - 1 => 'PhabricatorPolicyInterface', + 'DrydockDAO', + 'PhabricatorPolicyInterface', ), 'DrydockResourceCloseController' => 'DrydockResourceController', 'DrydockResourceController' => 'DrydockController', @@ -3450,13 +3450,13 @@ phutil_register_library_map(array( 'FileMailReceiver' => 'PhabricatorObjectMailReceiver', 'FileReplyHandler' => 'PhabricatorMailReplyHandler', 'HarbormasterBuild' => array( - 0 => 'HarbormasterDAO', - 1 => 'PhabricatorPolicyInterface', + 'HarbormasterDAO', + 'PhabricatorPolicyInterface', ), 'HarbormasterBuildActionController' => 'HarbormasterController', 'HarbormasterBuildArtifact' => array( - 0 => 'HarbormasterDAO', - 1 => 'PhabricatorPolicyInterface', + 'HarbormasterDAO', + 'PhabricatorPolicyInterface', ), 'HarbormasterBuildArtifactQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildCommand' => 'HarbormasterDAO', @@ -3464,19 +3464,19 @@ phutil_register_library_map(array( 'HarbormasterBuildItem' => 'HarbormasterDAO', 'HarbormasterBuildItemQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildLog' => array( - 0 => 'HarbormasterDAO', - 1 => 'PhabricatorPolicyInterface', + 'HarbormasterDAO', + 'PhabricatorPolicyInterface', ), 'HarbormasterBuildLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildMessage' => array( - 0 => 'HarbormasterDAO', - 1 => 'PhabricatorPolicyInterface', + 'HarbormasterDAO', + 'PhabricatorPolicyInterface', ), 'HarbormasterBuildMessageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildPlan' => array( - 0 => 'HarbormasterDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorSubscribableInterface', + 'HarbormasterDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorSubscribableInterface', ), 'HarbormasterBuildPlanDatasource' => 'PhabricatorTypeaheadDatasource', 'HarbormasterBuildPlanEditor' => 'PhabricatorApplicationTransactionEditor', @@ -3487,13 +3487,13 @@ phutil_register_library_map(array( 'HarbormasterBuildPlanTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildStep' => array( - 0 => 'HarbormasterDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorCustomFieldInterface', + 'HarbormasterDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorCustomFieldInterface', ), 'HarbormasterBuildStepCoreCustomField' => array( - 0 => 'HarbormasterBuildStepCustomField', - 1 => 'PhabricatorStandardCustomFieldInterface', + 'HarbormasterBuildStepCustomField', + 'PhabricatorStandardCustomFieldInterface', ), 'HarbormasterBuildStepCustomField' => 'PhabricatorCustomField', 'HarbormasterBuildStepEditor' => 'PhabricatorApplicationTransactionEditor', @@ -3501,8 +3501,8 @@ phutil_register_library_map(array( 'HarbormasterBuildStepTransaction' => 'PhabricatorApplicationTransaction', 'HarbormasterBuildStepTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'HarbormasterBuildTarget' => array( - 0 => 'HarbormasterDAO', - 1 => 'PhabricatorPolicyInterface', + 'HarbormasterDAO', + 'PhabricatorPolicyInterface', ), 'HarbormasterBuildTargetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildTransaction' => 'PhabricatorApplicationTransaction', @@ -3511,9 +3511,9 @@ phutil_register_library_map(array( 'HarbormasterBuildViewController' => 'HarbormasterController', 'HarbormasterBuildWorker' => 'HarbormasterWorker', 'HarbormasterBuildable' => array( - 0 => 'HarbormasterDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'HarbormasterBuildableInterface', + 'HarbormasterDAO', + 'PhabricatorPolicyInterface', + 'HarbormasterBuildableInterface', ), 'HarbormasterBuildableActionController' => 'HarbormasterController', 'HarbormasterBuildableListController' => 'HarbormasterController', @@ -3583,10 +3583,10 @@ phutil_register_library_map(array( 'HeraldRecursiveConditionsException' => 'Exception', 'HeraldRemarkupRule' => 'PhabricatorRemarkupRuleObject', 'HeraldRule' => array( - 0 => 'HeraldDAO', - 1 => 'PhabricatorFlaggableInterface', - 2 => 'PhabricatorPolicyInterface', - 3 => 'PhabricatorDestructableInterface', + 'HeraldDAO', + 'PhabricatorFlaggableInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorDestructibleInterface', ), 'HeraldRuleController' => 'HeraldController', 'HeraldRuleEdit' => 'HeraldDAO', @@ -3602,8 +3602,8 @@ phutil_register_library_map(array( 'HeraldTestConsoleController' => 'HeraldController', 'HeraldTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'HeraldTranscript' => array( - 0 => 'HeraldDAO', - 1 => 'PhabricatorPolicyInterface', + 'HeraldDAO', + 'PhabricatorPolicyInterface', ), 'HeraldTranscriptController' => 'HeraldController', 'HeraldTranscriptGarbageCollector' => 'PhabricatorGarbageCollector', @@ -3621,15 +3621,15 @@ phutil_register_library_map(array( 'LegalpadController' => 'PhabricatorController', 'LegalpadDAO' => 'PhabricatorLiskDAO', 'LegalpadDocument' => array( - 0 => 'LegalpadDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorSubscribableInterface', - 3 => 'PhabricatorApplicationTransactionInterface', - 4 => 'PhabricatorDestructableInterface', + 'LegalpadDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorApplicationTransactionInterface', + 'PhabricatorDestructibleInterface', ), 'LegalpadDocumentBody' => array( - 0 => 'LegalpadDAO', - 1 => 'PhabricatorMarkupInterface', + 'LegalpadDAO', + 'PhabricatorMarkupInterface', ), 'LegalpadDocumentCommentController' => 'LegalpadController', 'LegalpadDocumentDatasource' => 'PhabricatorTypeaheadDatasource', @@ -3643,8 +3643,8 @@ phutil_register_library_map(array( 'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine', 'LegalpadDocumentSignController' => 'LegalpadController', 'LegalpadDocumentSignature' => array( - 0 => 'LegalpadDAO', - 1 => 'PhabricatorPolicyInterface', + 'LegalpadDAO', + 'PhabricatorPolicyInterface', ), 'LegalpadDocumentSignatureAddController' => 'LegalpadController', 'LegalpadDocumentSignatureListController' => 'LegalpadController', @@ -3679,8 +3679,8 @@ phutil_register_library_map(array( 'ManiphestCapabilityEditProjects' => 'PhabricatorPolicyCapability', 'ManiphestCapabilityEditStatus' => 'PhabricatorPolicyCapability', 'ManiphestConfiguredCustomField' => array( - 0 => 'ManiphestCustomField', - 1 => 'PhabricatorStandardCustomFieldInterface', + 'ManiphestCustomField', + 'PhabricatorStandardCustomFieldInterface', ), 'ManiphestController' => 'PhabricatorController', 'ManiphestCreateMailReceiver' => 'PhabricatorMailReceiver', @@ -3705,15 +3705,15 @@ phutil_register_library_map(array( 'ManiphestSubpriorityController' => 'ManiphestController', 'ManiphestSubscribeController' => 'ManiphestController', 'ManiphestTask' => array( - 0 => 'ManiphestDAO', - 1 => 'PhabricatorMarkupInterface', - 2 => 'PhabricatorPolicyInterface', - 3 => 'PhabricatorTokenReceiverInterface', - 4 => 'PhabricatorFlaggableInterface', - 5 => 'PhrequentTrackableInterface', - 6 => 'PhabricatorCustomFieldInterface', - 7 => 'PhabricatorDestructableInterface', - 8 => 'PhabricatorApplicationTransactionInterface', + 'ManiphestDAO', + 'PhabricatorMarkupInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorTokenReceiverInterface', + 'PhabricatorFlaggableInterface', + 'PhrequentTrackableInterface', + 'PhabricatorCustomFieldInterface', + 'PhabricatorDestructibleInterface', + 'PhabricatorApplicationTransactionInterface', ), 'ManiphestTaskDescriptionPreviewController' => 'ManiphestController', 'ManiphestTaskDetailController' => 'ManiphestController', @@ -3749,8 +3749,8 @@ phutil_register_library_map(array( 'NuanceController' => 'PhabricatorController', 'NuanceDAO' => 'PhabricatorLiskDAO', 'NuanceItem' => array( - 0 => 'NuanceDAO', - 1 => 'PhabricatorPolicyInterface', + 'NuanceDAO', + 'PhabricatorPolicyInterface', ), 'NuanceItemEditController' => 'NuanceController', 'NuanceItemEditor' => 'PhabricatorApplicationTransactionEditor', @@ -3766,8 +3766,8 @@ phutil_register_library_map(array( 'NuancePhabricatorFormSourceDefinition' => 'NuanceSourceDefinition', 'NuanceQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'NuanceQueue' => array( - 0 => 'NuanceDAO', - 1 => 'PhabricatorPolicyInterface', + 'NuanceDAO', + 'PhabricatorPolicyInterface', ), 'NuanceQueueEditController' => 'NuanceController', 'NuanceQueueEditor' => 'PhabricatorApplicationTransactionEditor', @@ -3787,8 +3787,8 @@ phutil_register_library_map(array( 'NuanceRequestorTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'NuanceRequestorViewController' => 'NuanceController', 'NuanceSource' => array( - 0 => 'NuanceDAO', - 1 => 'PhabricatorPolicyInterface', + 'NuanceDAO', + 'PhabricatorPolicyInterface', ), 'NuanceSourceDefinition' => 'Phobject', 'NuanceSourceEditController' => 'NuanceController', @@ -3862,8 +3862,8 @@ phutil_register_library_map(array( 'PassphraseAbstractKey' => 'Phobject', 'PassphraseController' => 'PhabricatorController', 'PassphraseCredential' => array( - 0 => 'PassphraseDAO', - 1 => 'PhabricatorPolicyInterface', + 'PassphraseDAO', + 'PhabricatorPolicyInterface', ), 'PassphraseCredentialControl' => 'AphrontFormControl', 'PassphraseCredentialCreateController' => 'PassphraseController', @@ -3985,15 +3985,15 @@ phutil_register_library_map(array( 'PhabricatorApplicationTest' => 'PhabricatorApplication', 'PhabricatorApplicationTokens' => 'PhabricatorApplication', 'PhabricatorApplicationTransaction' => array( - 0 => 'PhabricatorLiskDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorDestructableInterface', + 'PhabricatorLiskDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorDestructibleInterface', ), 'PhabricatorApplicationTransactionComment' => array( - 0 => 'PhabricatorLiskDAO', - 1 => 'PhabricatorMarkupInterface', - 2 => 'PhabricatorPolicyInterface', - 3 => 'PhabricatorDestructableInterface', + 'PhabricatorLiskDAO', + 'PhabricatorMarkupInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorDestructibleInterface', ), 'PhabricatorApplicationTransactionCommentEditController' => 'PhabricatorApplicationTransactionController', 'PhabricatorApplicationTransactionCommentEditor' => 'PhabricatorEditor', @@ -4027,15 +4027,15 @@ phutil_register_library_map(array( 'PhabricatorAsanaConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorAuditAddCommentController' => 'PhabricatorAuditController', 'PhabricatorAuditComment' => array( - 0 => 'PhabricatorAuditDAO', - 1 => 'PhabricatorMarkupInterface', + 'PhabricatorAuditDAO', + 'PhabricatorMarkupInterface', ), 'PhabricatorAuditCommentEditor' => 'PhabricatorEditor', 'PhabricatorAuditController' => 'PhabricatorController', 'PhabricatorAuditDAO' => 'PhabricatorLiskDAO', 'PhabricatorAuditInlineComment' => array( - 0 => 'PhabricatorAuditDAO', - 1 => 'PhabricatorInlineCommentInterface', + 'PhabricatorAuditDAO', + 'PhabricatorInlineCommentInterface', ), 'PhabricatorAuditListController' => 'PhabricatorAuditController', 'PhabricatorAuditListView' => 'AphrontView', @@ -4073,8 +4073,8 @@ phutil_register_library_map(array( 'PhabricatorAuthOneTimeLoginController' => 'PhabricatorAuthController', 'PhabricatorAuthPHIDTypeAuthFactor' => 'PhabricatorPHIDType', 'PhabricatorAuthProviderConfig' => array( - 0 => 'PhabricatorAuthDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorAuthDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthController', 'PhabricatorAuthProviderConfigEditor' => 'PhabricatorApplicationTransactionEditor', @@ -4100,16 +4100,16 @@ phutil_register_library_map(array( 'PhabricatorAuthProviderPersona' => 'PhabricatorAuthProvider', 'PhabricatorAuthRegisterController' => 'PhabricatorAuthController', 'PhabricatorAuthSession' => array( - 0 => 'PhabricatorAuthDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorAuthDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorAuthSessionEngine' => 'Phobject', 'PhabricatorAuthSessionGarbageCollector' => 'PhabricatorGarbageCollector', 'PhabricatorAuthSessionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorAuthStartController' => 'PhabricatorAuthController', 'PhabricatorAuthTemporaryToken' => array( - 0 => 'PhabricatorAuthDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorAuthDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorAuthTemporaryTokenGarbageCollector' => 'PhabricatorGarbageCollector', 'PhabricatorAuthTemporaryTokenQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -4147,8 +4147,8 @@ phutil_register_library_map(array( 'PhabricatorCalendarController' => 'PhabricatorController', 'PhabricatorCalendarDAO' => 'PhabricatorLiskDAO', 'PhabricatorCalendarEvent' => array( - 0 => 'PhabricatorCalendarDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorCalendarDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorCalendarEventDeleteController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController', @@ -4165,8 +4165,8 @@ phutil_register_library_map(array( 'PhabricatorChangeParserTestCase' => 'PhabricatorWorkingCopyTestCase', 'PhabricatorChangesetResponse' => 'AphrontProxyResponse', 'PhabricatorChatLogChannel' => array( - 0 => 'PhabricatorChatLogDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorChatLogDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorChatLogChannelListController' => 'PhabricatorChatLogController', 'PhabricatorChatLogChannelLogController' => 'PhabricatorChatLogController', @@ -4174,8 +4174,8 @@ phutil_register_library_map(array( 'PhabricatorChatLogController' => 'PhabricatorController', 'PhabricatorChatLogDAO' => 'PhabricatorLiskDAO', 'PhabricatorChatLogEvent' => array( - 0 => 'PhabricatorChatLogDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorChatLogDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorChatLogEventType' => 'PhabricatorChatLogConstants', 'PhabricatorChatLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -4195,8 +4195,8 @@ phutil_register_library_map(array( 'PhabricatorConduitLogController' => 'PhabricatorConduitController', 'PhabricatorConduitLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorConduitMethodCallLog' => array( - 0 => 'PhabricatorConduitDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorConduitDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorConduitMethodQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorConduitSearchEngine' => 'PhabricatorApplicationSearchEngine', @@ -4209,8 +4209,8 @@ phutil_register_library_map(array( 'PhabricatorConfigEditController' => 'PhabricatorConfigController', 'PhabricatorConfigEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorConfigEntry' => array( - 0 => 'PhabricatorConfigEntryDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorConfigEntryDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorConfigEntryDAO' => 'PhabricatorLiskDAO', 'PhabricatorConfigEntryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -4228,8 +4228,8 @@ phutil_register_library_map(array( 'PhabricatorConfigManagementSetWorkflow' => 'PhabricatorConfigManagementWorkflow', 'PhabricatorConfigManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorConfigOption' => array( - 0 => 'Phobject', - 1 => 'PhabricatorMarkupInterface', + 'Phobject', + 'PhabricatorMarkupInterface', ), 'PhabricatorConfigPHIDTypeConfig' => 'PhabricatorPHIDType', 'PhabricatorConfigProxySource' => 'PhabricatorConfigSource', @@ -4245,8 +4245,8 @@ phutil_register_library_map(array( 'PhabricatorCookies' => 'Phobject', 'PhabricatorCoreConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorCountdown' => array( - 0 => 'PhabricatorCountdownDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorCountdownDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorCountdownCapabilityDefaultView' => 'PhabricatorPolicyCapability', 'PhabricatorCountdownController' => 'PhabricatorController', @@ -4281,8 +4281,8 @@ phutil_register_library_map(array( 'PhabricatorDaemonDAO' => 'PhabricatorLiskDAO', 'PhabricatorDaemonEventListener' => 'PhabricatorEventListener', 'PhabricatorDaemonLog' => array( - 0 => 'PhabricatorDaemonDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorDaemonDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorDaemonLogEvent' => 'PhabricatorDaemonDAO', 'PhabricatorDaemonLogEventGarbageCollector' => 'PhabricatorGarbageCollector', @@ -4304,8 +4304,8 @@ phutil_register_library_map(array( 'PhabricatorDaemonManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorDaemonTaskGarbageCollector' => 'PhabricatorGarbageCollector', 'PhabricatorDashboard' => array( - 0 => 'PhabricatorDashboardDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorDashboardDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorDashboardAddPanelController' => 'PhabricatorDashboardController', 'PhabricatorDashboardController' => 'PhabricatorController', @@ -4321,14 +4321,14 @@ phutil_register_library_map(array( 'PhabricatorDashboardPHIDTypeDashboard' => 'PhabricatorPHIDType', 'PhabricatorDashboardPHIDTypePanel' => 'PhabricatorPHIDType', 'PhabricatorDashboardPanel' => array( - 0 => 'PhabricatorDashboardDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorCustomFieldInterface', + 'PhabricatorDashboardDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorCustomFieldInterface', ), 'PhabricatorDashboardPanelArchiveController' => 'PhabricatorDashboardController', 'PhabricatorDashboardPanelCoreCustomField' => array( - 0 => 'PhabricatorDashboardPanelCustomField', - 1 => 'PhabricatorStandardCustomFieldInterface', + 'PhabricatorDashboardPanelCustomField', + 'PhabricatorStandardCustomFieldInterface', ), 'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField', 'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController', @@ -4391,8 +4391,8 @@ phutil_register_library_map(array( 'PhabricatorExampleEventListener' => 'PhabricatorEventListener', 'PhabricatorExtendingPhabricatorConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorExternalAccount' => array( - 0 => 'PhabricatorUserDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorUserDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorExternalAccountQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorFactAggregate' => 'PhabricatorFactDAO', @@ -4437,11 +4437,11 @@ phutil_register_library_map(array( 'PhabricatorFeedStoryStatus' => 'PhabricatorFeedStory', 'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants', 'PhabricatorFile' => array( - 0 => 'PhabricatorFileDAO', - 1 => 'PhabricatorTokenReceiverInterface', - 2 => 'PhabricatorSubscribableInterface', - 3 => 'PhabricatorFlaggableInterface', - 4 => 'PhabricatorPolicyInterface', + 'PhabricatorFileDAO', + 'PhabricatorTokenReceiverInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorPolicyInterface', ), 'PhabricatorFileCommentController' => 'PhabricatorFileController', 'PhabricatorFileComposeController' => 'PhabricatorFileController', @@ -4452,11 +4452,11 @@ phutil_register_library_map(array( 'PhabricatorFileDropUploadController' => 'PhabricatorFileController', 'PhabricatorFileEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorFileImageMacro' => array( - 0 => 'PhabricatorFileDAO', - 1 => 'PhabricatorSubscribableInterface', - 2 => 'PhabricatorApplicationTransactionInterface', - 3 => 'PhabricatorFlaggableInterface', - 4 => 'PhabricatorPolicyInterface', + 'PhabricatorFileDAO', + 'PhabricatorSubscribableInterface', + 'PhabricatorApplicationTransactionInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorPolicyInterface', ), 'PhabricatorFileInfoController' => 'PhabricatorFileController', 'PhabricatorFileLinkListView' => 'AphrontView', @@ -4485,8 +4485,8 @@ phutil_register_library_map(array( 'PhabricatorFilesManagementRebuildWorkflow' => 'PhabricatorFilesManagementWorkflow', 'PhabricatorFilesManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorFlag' => array( - 0 => 'PhabricatorFlagDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorFlagDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorFlagColor' => 'PhabricatorFlagConstants', 'PhabricatorFlagController' => 'PhabricatorController', @@ -4608,9 +4608,9 @@ phutil_register_library_map(array( 'PhabricatorMetaMTAMailableDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorMetaMTAMailgunReceiveController' => 'PhabricatorMetaMTAController', 'PhabricatorMetaMTAMailingList' => array( - 0 => 'PhabricatorMetaMTADAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorDestructableInterface', + 'PhabricatorMetaMTADAO', + 'PhabricatorPolicyInterface', + 'PhabricatorDestructibleInterface', ), 'PhabricatorMetaMTAMemberQuery' => 'PhabricatorQuery', 'PhabricatorMetaMTAPermanentFailureException' => 'Exception', @@ -4624,8 +4624,8 @@ phutil_register_library_map(array( 'PhabricatorMySQLConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorMySQLFileStorageEngine' => 'PhabricatorFileStorageEngine', 'PhabricatorNamedQuery' => array( - 0 => 'PhabricatorSearchDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorSearchDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorNamedQueryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorNotificationAdHocFeedStory' => 'PhabricatorFeedStory', @@ -4640,8 +4640,8 @@ phutil_register_library_map(array( 'PhabricatorNotificationStatusView' => 'AphrontTagView', 'PhabricatorNotificationTestController' => 'PhabricatorNotificationController', 'PhabricatorOAuthClientAuthorization' => array( - 0 => 'PhabricatorOAuthServerDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorOAuthServerDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorOAuthClientAuthorizationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorOAuthClientBaseController' => 'PhabricatorOAuthServerController', @@ -4656,8 +4656,8 @@ phutil_register_library_map(array( 'PhabricatorOAuthServerAuthorizationsSettingsPanel' => 'PhabricatorSettingsPanel', 'PhabricatorOAuthServerCapabilityCreateClients' => 'PhabricatorPolicyCapability', 'PhabricatorOAuthServerClient' => array( - 0 => 'PhabricatorOAuthServerDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorOAuthServerDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorOAuthServerClientQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorOAuthServerClientSearchEngine' => 'PhabricatorApplicationSearchEngine', @@ -4685,8 +4685,8 @@ phutil_register_library_map(array( 'PhabricatorOwnersOwner' => 'PhabricatorOwnersDAO', 'PhabricatorOwnersPHIDTypePackage' => 'PhabricatorPHIDType', 'PhabricatorOwnersPackage' => array( - 0 => 'PhabricatorOwnersDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorOwnersDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorOwnersPackageDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorOwnersPackageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -4699,12 +4699,12 @@ phutil_register_library_map(array( 'PhabricatorPasswordHasherTestCase' => 'PhabricatorTestCase', 'PhabricatorPasswordHasherUnavailableException' => 'Exception', 'PhabricatorPaste' => array( - 0 => 'PhabricatorPasteDAO', - 1 => 'PhabricatorSubscribableInterface', - 2 => 'PhabricatorTokenReceiverInterface', - 3 => 'PhabricatorFlaggableInterface', - 4 => 'PhabricatorPolicyInterface', - 5 => 'PhabricatorProjectInterface', + 'PhabricatorPasteDAO', + 'PhabricatorSubscribableInterface', + 'PhabricatorTokenReceiverInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorProjectInterface', ), 'PhabricatorPasteCommentController' => 'PhabricatorPasteController', 'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions', @@ -4757,8 +4757,8 @@ phutil_register_library_map(array( 'PhabricatorPhrictionConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorPolicies' => 'PhabricatorPolicyConstants', 'PhabricatorPolicy' => array( - 0 => 'PhabricatorPolicyDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorPolicyDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorPolicyAwareQuery' => 'PhabricatorOffsetPagedQuery', 'PhabricatorPolicyAwareTestQuery' => 'PhabricatorPolicyAwareQuery', @@ -4788,12 +4788,12 @@ phutil_register_library_map(array( 'PhabricatorPolicyTestObject' => 'PhabricatorPolicyInterface', 'PhabricatorPolicyType' => 'PhabricatorPolicyConstants', 'PhabricatorProject' => array( - 0 => 'PhabricatorProjectDAO', - 1 => 'PhabricatorFlaggableInterface', - 2 => 'PhabricatorPolicyInterface', - 3 => 'PhabricatorSubscribableInterface', - 4 => 'PhabricatorCustomFieldInterface', - 5 => 'PhabricatorDestructableInterface', + 'PhabricatorProjectDAO', + 'PhabricatorFlaggableInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorCustomFieldInterface', + 'PhabricatorDestructibleInterface', ), 'PhabricatorProjectArchiveController' => 'PhabricatorProjectController', 'PhabricatorProjectBoardController' => 'PhabricatorProjectController', @@ -4802,9 +4802,9 @@ phutil_register_library_map(array( 'PhabricatorProjectBoardReorderController' => 'PhabricatorProjectBoardController', 'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController', 'PhabricatorProjectColumn' => array( - 0 => 'PhabricatorProjectDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorDestructableInterface', + 'PhabricatorProjectDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorDestructibleInterface', ), 'PhabricatorProjectColumnDetailController' => 'PhabricatorProjectBoardController', 'PhabricatorProjectColumnQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -4813,8 +4813,8 @@ phutil_register_library_map(array( 'PhabricatorProjectColumnTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhabricatorProjectConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorProjectConfiguredCustomField' => array( - 0 => 'PhabricatorProjectStandardCustomField', - 1 => 'PhabricatorStandardCustomFieldInterface', + 'PhabricatorProjectStandardCustomField', + 'PhabricatorStandardCustomFieldInterface', ), 'PhabricatorProjectController' => 'PhabricatorController', 'PhabricatorProjectCreateController' => 'PhabricatorProjectController', @@ -4847,8 +4847,8 @@ phutil_register_library_map(array( 'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorProjectSlug' => 'PhabricatorProjectDAO', 'PhabricatorProjectStandardCustomField' => array( - 0 => 'PhabricatorProjectCustomField', - 1 => 'PhabricatorStandardCustomFieldInterface', + 'PhabricatorProjectCustomField', + 'PhabricatorStandardCustomFieldInterface', ), 'PhabricatorProjectTestDataGenerator' => 'PhabricatorTestDataGenerator', 'PhabricatorProjectTransaction' => 'PhabricatorApplicationTransaction', @@ -4876,33 +4876,33 @@ phutil_register_library_map(array( 'PhabricatorRemarkupRuleObject' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRuleYoutube' => 'PhutilRemarkupRule', 'PhabricatorRepository' => array( - 0 => 'PhabricatorRepositoryDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorFlaggableInterface', - 3 => 'PhabricatorMarkupInterface', - 4 => 'PhabricatorDestructableInterface', - 5 => 'PhabricatorProjectInterface', + 'PhabricatorRepositoryDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorMarkupInterface', + 'PhabricatorDestructibleInterface', + 'PhabricatorProjectInterface', ), 'PhabricatorRepositoryArcanistProject' => array( - 0 => 'PhabricatorRepositoryDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorDestructableInterface', + 'PhabricatorRepositoryDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorDestructibleInterface', ), 'PhabricatorRepositoryArcanistProjectDeleteController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryArcanistProjectEditController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryArcanistProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorRepositoryAuditRequest' => array( - 0 => 'PhabricatorRepositoryDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorRepositoryDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorRepositoryBranch' => 'PhabricatorRepositoryDAO', 'PhabricatorRepositoryCommit' => array( - 0 => 'PhabricatorRepositoryDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorFlaggableInterface', - 3 => 'PhabricatorTokenReceiverInterface', - 4 => 'HarbormasterBuildableInterface', - 5 => 'PhabricatorCustomFieldInterface', + 'PhabricatorRepositoryDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorTokenReceiverInterface', + 'HarbormasterBuildableInterface', + 'PhabricatorCustomFieldInterface', ), 'PhabricatorRepositoryCommitChangeParserWorker' => 'PhabricatorRepositoryCommitParserWorker', 'PhabricatorRepositoryCommitData' => 'PhabricatorRepositoryDAO', @@ -4936,8 +4936,8 @@ phutil_register_library_map(array( 'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker', 'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker', 'PhabricatorRepositoryMirror' => array( - 0 => 'PhabricatorRepositoryDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorRepositoryDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorRepositoryMirrorEngine' => 'PhabricatorRepositoryEngine', 'PhabricatorRepositoryMirrorQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -4951,13 +4951,13 @@ phutil_register_library_map(array( 'PhabricatorRepositoryPullEngine' => 'PhabricatorRepositoryEngine', 'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon', 'PhabricatorRepositoryPushEvent' => array( - 0 => 'PhabricatorRepositoryDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorRepositoryDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorRepositoryPushEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorRepositoryPushLog' => array( - 0 => 'PhabricatorRepositoryDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorRepositoryDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorRepositoryPushLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorRepositoryPushLogSearchEngine' => 'PhabricatorApplicationSearchEngine', @@ -4965,8 +4965,8 @@ phutil_register_library_map(array( 'PhabricatorRepositoryPushReplyHandler' => 'PhabricatorMailReplyHandler', 'PhabricatorRepositoryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorRepositoryRefCursor' => array( - 0 => 'PhabricatorRepositoryDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorRepositoryDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorRepositoryRefCursorQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorRepositoryRefEngine' => 'PhabricatorRepositoryEngine', @@ -5001,8 +5001,8 @@ phutil_register_library_map(array( 'PhabricatorSSHPassthruCommand' => 'Phobject', 'PhabricatorSSHWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorSavedQuery' => array( - 0 => 'PhabricatorSearchDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorSearchDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorSavedQueryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorSearchApplicationSearchEngine' => 'PhabricatorApplicationSearchEngine', @@ -5085,12 +5085,12 @@ phutil_register_library_map(array( 'PhabricatorSlowvoteOption' => 'PhabricatorSlowvoteDAO', 'PhabricatorSlowvotePHIDTypePoll' => 'PhabricatorPHIDType', 'PhabricatorSlowvotePoll' => array( - 0 => 'PhabricatorSlowvoteDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorSubscribableInterface', - 3 => 'PhabricatorFlaggableInterface', - 4 => 'PhabricatorTokenReceiverInterface', - 5 => 'PhabricatorProjectInterface', + 'PhabricatorSlowvoteDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorTokenReceiverInterface', + 'PhabricatorProjectInterface', ), 'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController', 'PhabricatorSlowvoteQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -5149,8 +5149,8 @@ phutil_register_library_map(array( 'PhabricatorTestWorker' => 'PhabricatorWorker', 'PhabricatorTimeTestCase' => 'PhabricatorTestCase', 'PhabricatorToken' => array( - 0 => 'PhabricatorTokenDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorTokenDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorTokenController' => 'PhabricatorController', 'PhabricatorTokenCount' => 'PhabricatorTokenDAO', @@ -5158,8 +5158,8 @@ phutil_register_library_map(array( 'PhabricatorTokenDAO' => 'PhabricatorLiskDAO', 'PhabricatorTokenGiveController' => 'PhabricatorTokenController', 'PhabricatorTokenGiven' => array( - 0 => 'PhabricatorTokenDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorTokenDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorTokenGivenController' => 'PhabricatorTokenController', 'PhabricatorTokenGivenEditor' => 'PhabricatorEditor', @@ -5192,17 +5192,17 @@ phutil_register_library_map(array( 'PhabricatorUITooltipExample' => 'PhabricatorUIExample', 'PhabricatorUnitsTestCase' => 'PhabricatorTestCase', 'PhabricatorUser' => array( - 0 => 'PhabricatorUserDAO', - 1 => 'PhutilPerson', - 2 => 'PhabricatorPolicyInterface', - 3 => 'PhabricatorCustomFieldInterface', - 4 => 'PhabricatorDestructableInterface', + 'PhabricatorUserDAO', + 'PhutilPerson', + 'PhabricatorPolicyInterface', + 'PhabricatorCustomFieldInterface', + 'PhabricatorDestructibleInterface', ), 'PhabricatorUserBlurbField' => 'PhabricatorUserCustomField', 'PhabricatorUserConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorUserConfiguredCustomField' => array( - 0 => 'PhabricatorUserCustomField', - 1 => 'PhabricatorStandardCustomFieldInterface', + 'PhabricatorUserCustomField', + 'PhabricatorStandardCustomFieldInterface', ), 'PhabricatorUserConfiguredCustomFieldStorage' => 'PhabricatorCustomFieldStorage', 'PhabricatorUserCustomField' => 'PhabricatorCustomField', @@ -5214,8 +5214,8 @@ phutil_register_library_map(array( 'PhabricatorUserEmail' => 'PhabricatorUserDAO', 'PhabricatorUserEmailTestCase' => 'PhabricatorTestCase', 'PhabricatorUserLog' => array( - 0 => 'PhabricatorUserDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhabricatorUserDAO', + 'PhabricatorPolicyInterface', ), 'PhabricatorUserLogView' => 'AphrontView', 'PhabricatorUserPreferences' => 'PhabricatorUserDAO', @@ -5266,9 +5266,9 @@ phutil_register_library_map(array( 'PhameBasicBlogSkin' => 'PhameBlogSkin', 'PhameBasicTemplateBlogSkin' => 'PhameBasicBlogSkin', 'PhameBlog' => array( - 0 => 'PhameDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorMarkupInterface', + 'PhameDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorMarkupInterface', ), 'PhameBlogDeleteController' => 'PhameController', 'PhameBlogEditController' => 'PhameController', @@ -5282,10 +5282,10 @@ phutil_register_library_map(array( 'PhameController' => 'PhabricatorController', 'PhameDAO' => 'PhabricatorLiskDAO', 'PhamePost' => array( - 0 => 'PhameDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorMarkupInterface', - 3 => 'PhabricatorTokenReceiverInterface', + 'PhameDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorMarkupInterface', + 'PhabricatorTokenReceiverInterface', ), 'PhamePostDeleteController' => 'PhameController', 'PhamePostEditController' => 'PhameController', @@ -5308,9 +5308,9 @@ phutil_register_library_map(array( 'PhluxTransaction' => 'PhabricatorApplicationTransaction', 'PhluxTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhluxVariable' => array( - 0 => 'PhluxDAO', - 1 => 'PhabricatorFlaggableInterface', - 2 => 'PhabricatorPolicyInterface', + 'PhluxDAO', + 'PhabricatorFlaggableInterface', + 'PhabricatorPolicyInterface', ), 'PhluxVariableEditor' => 'PhabricatorApplicationTransactionEditor', 'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', @@ -5321,9 +5321,9 @@ phutil_register_library_map(array( 'PholioController' => 'PhabricatorController', 'PholioDAO' => 'PhabricatorLiskDAO', 'PholioImage' => array( - 0 => 'PholioDAO', - 1 => 'PhabricatorMarkupInterface', - 2 => 'PhabricatorPolicyInterface', + 'PholioDAO', + 'PhabricatorMarkupInterface', + 'PhabricatorPolicyInterface', ), 'PholioImageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PholioImageUploadController' => 'PholioController', @@ -5331,15 +5331,15 @@ phutil_register_library_map(array( 'PholioInlineListController' => 'PholioController', 'PholioInlineThumbController' => 'PholioController', 'PholioMock' => array( - 0 => 'PholioDAO', - 1 => 'PhabricatorMarkupInterface', - 2 => 'PhabricatorPolicyInterface', - 3 => 'PhabricatorSubscribableInterface', - 4 => 'PhabricatorTokenReceiverInterface', - 5 => 'PhabricatorFlaggableInterface', - 6 => 'PhabricatorApplicationTransactionInterface', - 7 => 'PhabricatorProjectInterface', - 8 => 'PhabricatorDestructableInterface', + 'PholioDAO', + 'PhabricatorMarkupInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorTokenReceiverInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorApplicationTransactionInterface', + 'PhabricatorProjectInterface', + 'PhabricatorDestructibleInterface', ), 'PholioMockCommentController' => 'PholioController', 'PholioMockEditController' => 'PholioController', @@ -5364,8 +5364,8 @@ phutil_register_library_map(array( 'PholioTransactionView' => 'PhabricatorApplicationTransactionView', 'PholioUploadedImageView' => 'AphrontView', 'PhortuneAccount' => array( - 0 => 'PhortuneDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhortuneDAO', + 'PhabricatorPolicyInterface', ), 'PhortuneAccountBuyController' => 'PhortuneController', 'PhortuneAccountEditor' => 'PhabricatorApplicationTransactionEditor', @@ -5386,8 +5386,8 @@ phutil_register_library_map(array( 'PhortuneNoPaymentProviderException' => 'Exception', 'PhortuneNotImplementedException' => 'Exception', 'PhortunePaymentMethod' => array( - 0 => 'PhortuneDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhortuneDAO', + 'PhabricatorPolicyInterface', ), 'PhortunePaymentMethodEditController' => 'PhortuneController', 'PhortunePaymentMethodListController' => 'PhabricatorController', @@ -5396,8 +5396,8 @@ phutil_register_library_map(array( 'PhortunePaymentProviderTestCase' => 'PhabricatorTestCase', 'PhortunePaypalPaymentProvider' => 'PhortunePaymentProvider', 'PhortuneProduct' => array( - 0 => 'PhortuneDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhortuneDAO', + 'PhabricatorPolicyInterface', ), 'PhortuneProductEditController' => 'PhabricatorController', 'PhortuneProductEditor' => 'PhabricatorApplicationTransactionEditor', @@ -5418,13 +5418,13 @@ phutil_register_library_map(array( 'PhragmentCreateController' => 'PhragmentController', 'PhragmentDAO' => 'PhabricatorLiskDAO', 'PhragmentFragment' => array( - 0 => 'PhragmentDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhragmentDAO', + 'PhabricatorPolicyInterface', ), 'PhragmentFragmentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhragmentFragmentVersion' => array( - 0 => 'PhragmentDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhragmentDAO', + 'PhabricatorPolicyInterface', ), 'PhragmentFragmentVersionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhragmentHistoryController' => 'PhragmentController', @@ -5436,12 +5436,12 @@ phutil_register_library_map(array( 'PhragmentPolicyController' => 'PhragmentController', 'PhragmentRevertController' => 'PhragmentController', 'PhragmentSnapshot' => array( - 0 => 'PhragmentDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhragmentDAO', + 'PhabricatorPolicyInterface', ), 'PhragmentSnapshotChild' => array( - 0 => 'PhragmentDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhragmentDAO', + 'PhabricatorPolicyInterface', ), 'PhragmentSnapshotChildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhragmentSnapshotCreateController' => 'PhragmentController', @@ -5463,27 +5463,28 @@ phutil_register_library_map(array( 'PhrequentTrackingEditor' => 'PhabricatorEditor', 'PhrequentUIEventListener' => 'PhabricatorEventListener', 'PhrequentUserTime' => array( - 0 => 'PhrequentDAO', - 1 => 'PhabricatorPolicyInterface', + 'PhrequentDAO', + 'PhabricatorPolicyInterface', ), 'PhrequentUserTimeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhrictionActionConstants' => 'PhrictionConstants', 'PhrictionActionMenuEventListener' => 'PhabricatorEventListener', 'PhrictionChangeType' => 'PhrictionConstants', 'PhrictionContent' => array( - 0 => 'PhrictionDAO', - 1 => 'PhabricatorMarkupInterface', + 'PhrictionDAO', + 'PhabricatorMarkupInterface', ), 'PhrictionController' => 'PhabricatorController', 'PhrictionDAO' => 'PhabricatorLiskDAO', 'PhrictionDeleteController' => 'PhrictionController', 'PhrictionDiffController' => 'PhrictionController', 'PhrictionDocument' => array( - 0 => 'PhrictionDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorSubscribableInterface', - 3 => 'PhabricatorFlaggableInterface', - 4 => 'PhabricatorTokenReceiverInterface', + 'PhrictionDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorTokenReceiverInterface', + 'PhabricatorDestructibleInterface', ), 'PhrictionDocumentController' => 'PhrictionController', 'PhrictionDocumentEditor' => 'PhabricatorEditor', @@ -5502,13 +5503,13 @@ phutil_register_library_map(array( 'PhrictionSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PonderAddAnswerView' => 'AphrontView', 'PonderAnswer' => array( - 0 => 'PonderDAO', - 1 => 'PhabricatorMarkupInterface', - 2 => 'PonderVotableInterface', - 3 => 'PhabricatorPolicyInterface', - 4 => 'PhabricatorFlaggableInterface', - 5 => 'PhabricatorSubscribableInterface', - 6 => 'PhabricatorTokenReceiverInterface', + 'PonderDAO', + 'PhabricatorMarkupInterface', + 'PonderVotableInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorTokenReceiverInterface', ), 'PonderAnswerCommentController' => 'PonderController', 'PonderAnswerEditController' => 'PonderController', @@ -5520,8 +5521,8 @@ phutil_register_library_map(array( 'PonderAnswerTransactionComment' => 'PhabricatorApplicationTransactionComment', 'PonderAnswerTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PonderComment' => array( - 0 => 'PonderDAO', - 1 => 'PhabricatorMarkupInterface', + 'PonderDAO', + 'PhabricatorMarkupInterface', ), 'PonderCommentQuery' => 'PhabricatorQuery', 'PonderController' => 'PhabricatorController', @@ -5530,14 +5531,14 @@ phutil_register_library_map(array( 'PonderPHIDTypeAnswer' => 'PhabricatorPHIDType', 'PonderPHIDTypeQuestion' => 'PhabricatorPHIDType', 'PonderQuestion' => array( - 0 => 'PonderDAO', - 1 => 'PhabricatorMarkupInterface', - 2 => 'PonderVotableInterface', - 3 => 'PhabricatorSubscribableInterface', - 4 => 'PhabricatorFlaggableInterface', - 5 => 'PhabricatorPolicyInterface', - 6 => 'PhabricatorTokenReceiverInterface', - 7 => 'PhabricatorProjectInterface', + 'PonderDAO', + 'PhabricatorMarkupInterface', + 'PonderVotableInterface', + 'PhabricatorSubscribableInterface', + 'PhabricatorFlaggableInterface', + 'PhabricatorPolicyInterface', + 'PhabricatorTokenReceiverInterface', + 'PhabricatorProjectInterface', ), 'PonderQuestionCommentController' => 'PonderController', 'PonderQuestionEditController' => 'PonderController', @@ -5566,8 +5567,8 @@ phutil_register_library_map(array( 'QueryFormattingTestCase' => 'PhabricatorTestCase', 'ReleephAuthorFieldSpecification' => 'ReleephFieldSpecification', 'ReleephBranch' => array( - 0 => 'ReleephDAO', - 1 => 'PhabricatorPolicyInterface', + 'ReleephDAO', + 'PhabricatorPolicyInterface', ), 'ReleephBranchAccessController' => 'ReleephBranchController', 'ReleephBranchCommitFieldSpecification' => 'ReleephFieldSpecification', @@ -5583,8 +5584,8 @@ phutil_register_library_map(array( 'ReleephBranchTransaction' => 'PhabricatorApplicationTransaction', 'ReleephBranchTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'ReleephBranchViewController' => array( - 0 => 'ReleephBranchController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', + 'ReleephBranchController', + 'PhabricatorApplicationSearchResultsControllerInterface', ), 'ReleephCommitFinderException' => 'Exception', 'ReleephCommitMessageFieldSpecification' => 'ReleephFieldSpecification', @@ -5597,8 +5598,8 @@ phutil_register_library_map(array( 'ReleephDiffSizeFieldSpecification' => 'ReleephFieldSpecification', 'ReleephFieldParseException' => 'Exception', 'ReleephFieldSpecification' => array( - 0 => 'PhabricatorCustomField', - 1 => 'PhabricatorMarkupInterface', + 'PhabricatorCustomField', + 'PhabricatorMarkupInterface', ), 'ReleephIntentFieldSpecification' => 'ReleephFieldSpecification', 'ReleephLevelFieldSpecification' => 'ReleephFieldSpecification', @@ -5618,18 +5619,18 @@ phutil_register_library_map(array( 'ReleephProductTransaction' => 'PhabricatorApplicationTransaction', 'ReleephProductTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'ReleephProductViewController' => array( - 0 => 'ReleephProductController', - 1 => 'PhabricatorApplicationSearchResultsControllerInterface', + 'ReleephProductController', + 'PhabricatorApplicationSearchResultsControllerInterface', ), 'ReleephProject' => array( - 0 => 'ReleephDAO', - 1 => 'PhabricatorPolicyInterface', + 'ReleephDAO', + 'PhabricatorPolicyInterface', ), 'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification', 'ReleephRequest' => array( - 0 => 'ReleephDAO', - 1 => 'PhabricatorPolicyInterface', - 2 => 'PhabricatorCustomFieldInterface', + 'ReleephDAO', + 'PhabricatorPolicyInterface', + 'PhabricatorCustomFieldInterface', ), 'ReleephRequestActionController' => 'ReleephRequestController', 'ReleephRequestCommentController' => 'ReleephRequestController', diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php index e0a0e7da59..5f92f05313 100644 --- a/src/applications/differential/storage/DifferentialDiff.php +++ b/src/applications/differential/storage/DifferentialDiff.php @@ -6,7 +6,7 @@ final class DifferentialDiff PhabricatorPolicyInterface, HarbormasterBuildableInterface, PhabricatorApplicationTransactionInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { protected $revisionID; protected $authorPHID; @@ -392,7 +392,7 @@ final class DifferentialDiff } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/differential/storage/DifferentialRevision.php b/src/applications/differential/storage/DifferentialRevision.php index 2446e67173..a7146a8ccb 100644 --- a/src/applications/differential/storage/DifferentialRevision.php +++ b/src/applications/differential/storage/DifferentialRevision.php @@ -10,7 +10,7 @@ final class DifferentialRevision extends DifferentialDAO PhabricatorSubscribableInterface, PhabricatorCustomFieldInterface, PhabricatorApplicationTransactionInterface, - PhabricatorDestructableInterface, + PhabricatorDestructibleInterface, PhabricatorProjectInterface { protected $title = ''; @@ -449,7 +449,7 @@ final class DifferentialRevision extends DifferentialDAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php index 15e85646ed..6245f70d8f 100644 --- a/src/applications/herald/storage/HeraldRule.php +++ b/src/applications/herald/storage/HeraldRule.php @@ -4,7 +4,7 @@ final class HeraldRule extends HeraldDAO implements PhabricatorFlaggableInterface, PhabricatorPolicyInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { const TABLE_RULE_APPLIED = 'herald_ruleapplied'; @@ -252,7 +252,7 @@ final class HeraldRule extends HeraldDAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { diff --git a/src/applications/legalpad/storage/LegalpadDocument.php b/src/applications/legalpad/storage/LegalpadDocument.php index 2adaa42263..77f2be7cc4 100644 --- a/src/applications/legalpad/storage/LegalpadDocument.php +++ b/src/applications/legalpad/storage/LegalpadDocument.php @@ -5,7 +5,7 @@ final class LegalpadDocument extends LegalpadDAO PhabricatorPolicyInterface, PhabricatorSubscribableInterface, PhabricatorApplicationTransactionInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { protected $title; protected $contributorCount; @@ -201,7 +201,7 @@ final class LegalpadDocument extends LegalpadDAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php b/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php index 578c3cf744..e506815a0f 100644 --- a/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php +++ b/src/applications/mailinglists/storage/PhabricatorMetaMTAMailingList.php @@ -3,7 +3,7 @@ final class PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO implements PhabricatorPolicyInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { protected $name; protected $email; @@ -43,7 +43,7 @@ final class PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index fbba84c01c..3ee65438fa 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -8,7 +8,7 @@ final class ManiphestTask extends ManiphestDAO PhabricatorFlaggableInterface, PhrequentTrackableInterface, PhabricatorCustomFieldInterface, - PhabricatorDestructableInterface, + PhabricatorDestructibleInterface, PhabricatorApplicationTransactionInterface { const MARKUP_FIELD_DESCRIPTION = 'markup:desc'; @@ -285,7 +285,7 @@ final class ManiphestTask extends ManiphestDAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/people/storage/PhabricatorUser.php b/src/applications/people/storage/PhabricatorUser.php index 53a883106e..ed9ac15fa0 100644 --- a/src/applications/people/storage/PhabricatorUser.php +++ b/src/applications/people/storage/PhabricatorUser.php @@ -9,7 +9,7 @@ final class PhabricatorUser PhutilPerson, PhabricatorPolicyInterface, PhabricatorCustomFieldInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { const SESSION_TABLE = 'phabricator_session'; const NAMETOKEN_TABLE = 'user_nametoken'; @@ -821,7 +821,7 @@ EOBODY; } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php index d08859286b..c4c1e58f67 100644 --- a/src/applications/pholio/storage/PholioMock.php +++ b/src/applications/pholio/storage/PholioMock.php @@ -9,7 +9,7 @@ final class PholioMock extends PholioDAO PhabricatorFlaggableInterface, PhabricatorApplicationTransactionInterface, PhabricatorProjectInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { const MARKUP_FIELD_DESCRIPTION = 'markup:description'; @@ -258,7 +258,7 @@ final class PholioMock extends PholioDAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php index 07a3d5ec0f..9ba8fbccf1 100644 --- a/src/applications/phriction/storage/PhrictionDocument.php +++ b/src/applications/phriction/storage/PhrictionDocument.php @@ -6,7 +6,7 @@ final class PhrictionDocument extends PhrictionDAO PhabricatorSubscribableInterface, PhabricatorFlaggableInterface, PhabricatorTokenReceiverInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { protected $slug; protected $depth; @@ -183,7 +183,7 @@ final class PhrictionDocument extends PhrictionDAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php index fbcf331509..498f3bf2a7 100644 --- a/src/applications/project/storage/PhabricatorProject.php +++ b/src/applications/project/storage/PhabricatorProject.php @@ -6,7 +6,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO PhabricatorPolicyInterface, PhabricatorSubscribableInterface, PhabricatorCustomFieldInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { protected $name; protected $status = PhabricatorProjectStatus::STATUS_ACTIVE; @@ -308,7 +308,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { diff --git a/src/applications/project/storage/PhabricatorProjectColumn.php b/src/applications/project/storage/PhabricatorProjectColumn.php index 8b7d79dc7b..54f70a6714 100644 --- a/src/applications/project/storage/PhabricatorProjectColumn.php +++ b/src/applications/project/storage/PhabricatorProjectColumn.php @@ -2,8 +2,9 @@ final class PhabricatorProjectColumn extends PhabricatorProjectDAO - implements PhabricatorPolicyInterface, - PhabricatorDestructableInterface { + implements + PhabricatorPolicyInterface, + PhabricatorDestructibleInterface { const STATUS_ACTIVE = 0; const STATUS_HIDDEN = 1; @@ -99,7 +100,7 @@ final class PhabricatorProjectColumn } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index d1b5e6614a..2cfd178f50 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -8,7 +8,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO PhabricatorPolicyInterface, PhabricatorFlaggableInterface, PhabricatorMarkupInterface, - PhabricatorDestructableInterface, + PhabricatorDestructibleInterface, PhabricatorProjectInterface { /** @@ -1387,7 +1387,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { diff --git a/src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php b/src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php index 2d3b33366b..1665845cf1 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php +++ b/src/applications/repository/storage/PhabricatorRepositoryArcanistProject.php @@ -2,8 +2,9 @@ final class PhabricatorRepositoryArcanistProject extends PhabricatorRepositoryDAO - implements PhabricatorPolicyInterface, - PhabricatorDestructableInterface { + implements + PhabricatorPolicyInterface, + PhabricatorDestructibleInterface { protected $name; protected $repositoryID; @@ -89,7 +90,7 @@ final class PhabricatorRepositoryArcanistProject } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { diff --git a/src/applications/system/engine/PhabricatorDestructionEngine.php b/src/applications/system/engine/PhabricatorDestructionEngine.php index eedda85151..4c49ac6ae2 100644 --- a/src/applications/system/engine/PhabricatorDestructionEngine.php +++ b/src/applications/system/engine/PhabricatorDestructionEngine.php @@ -4,7 +4,7 @@ final class PhabricatorDestructionEngine extends Phobject { private $rootLogID; - public function destroyObject(PhabricatorDestructableInterface $object) { + public function destroyObject(PhabricatorDestructibleInterface $object) { $log = id(new PhabricatorSystemDestructionLog()) ->setEpoch(time()) ->setObjectClass(get_class($object)); diff --git a/src/applications/system/interface/PhabricatorDestructableInterface.php b/src/applications/system/interface/PhabricatorDestructibleInterface.php similarity index 89% rename from src/applications/system/interface/PhabricatorDestructableInterface.php rename to src/applications/system/interface/PhabricatorDestructibleInterface.php index 6130789f3a..3b69f87c3a 100644 --- a/src/applications/system/interface/PhabricatorDestructableInterface.php +++ b/src/applications/system/interface/PhabricatorDestructibleInterface.php @@ -1,6 +1,6 @@ $object) { - if (!($object instanceof PhabricatorDestructableInterface)) { + if (!($object instanceof PhabricatorDestructibleInterface)) { throw new PhutilArgumentUsageException( pht( 'Object "%s" can not be destroyed (it does not implement %s).', $object_name, - 'PhabricatorDestructableInterface')); + 'PhabricatorDestructibleInterface')); } } diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php index b1a0267fcd..a45406e20b 100644 --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -4,7 +4,7 @@ abstract class PhabricatorApplicationTransaction extends PhabricatorLiskDAO implements PhabricatorPolicyInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { const TARGET_TEXT = 'text'; const TARGET_HTML = 'html'; @@ -1026,7 +1026,7 @@ abstract class PhabricatorApplicationTransaction } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php b/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php index 318c3249b1..deaf110ea4 100644 --- a/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransactionComment.php @@ -5,7 +5,7 @@ abstract class PhabricatorApplicationTransactionComment implements PhabricatorMarkupInterface, PhabricatorPolicyInterface, - PhabricatorDestructableInterface { + PhabricatorDestructibleInterface { const MARKUP_FIELD_COMMENT = 'markup:comment'; @@ -135,7 +135,7 @@ abstract class PhabricatorApplicationTransactionComment } -/* -( PhabricatorDestructableInterface )----------------------------------- */ +/* -( PhabricatorDestructibleInterface )----------------------------------- */ public function destroyObjectPermanently( PhabricatorDestructionEngine $engine) { From 37106c1b317857abc978f0397406fbab866e861c Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 22 Jul 2014 00:05:17 +1000 Subject: [PATCH 41/44] Don't explicitly name abstract base classes Summary: Ref T5655. It is superfluous to include "base" in the name of an abstract base class. Furthermore, it is not done consistently within the code base. Test Plan: Ran `arc unit`. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5655 Differential Revision: https://secure.phabricator.com/D9989 --- src/__phutil_library_map__.php | 12 ++++++------ ...ller.php => PhabricatorOAuthClientController.php} | 2 +- .../PhabricatorOAuthClientDeleteController.php | 2 +- .../client/PhabricatorOAuthClientEditController.php | 2 +- .../client/PhabricatorOAuthClientListController.php | 2 +- .../client/PhabricatorOAuthClientViewController.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) rename src/applications/oauthserver/controller/client/{PhabricatorOAuthClientBaseController.php => PhabricatorOAuthClientController.php} (93%) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index bd539556ec..541d2a9b20 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1835,7 +1835,7 @@ phutil_register_library_map(array( 'PhabricatorNotificationTestController' => 'applications/notification/controller/PhabricatorNotificationTestController.php', 'PhabricatorOAuthClientAuthorization' => 'applications/oauthserver/storage/PhabricatorOAuthClientAuthorization.php', 'PhabricatorOAuthClientAuthorizationQuery' => 'applications/oauthserver/query/PhabricatorOAuthClientAuthorizationQuery.php', - 'PhabricatorOAuthClientBaseController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientBaseController.php', + 'PhabricatorOAuthClientController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientController.php', 'PhabricatorOAuthClientDeleteController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientDeleteController.php', 'PhabricatorOAuthClientEditController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php', 'PhabricatorOAuthClientListController' => 'applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php', @@ -4644,11 +4644,11 @@ phutil_register_library_map(array( 'PhabricatorPolicyInterface', ), 'PhabricatorOAuthClientAuthorizationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'PhabricatorOAuthClientBaseController' => 'PhabricatorOAuthServerController', - 'PhabricatorOAuthClientDeleteController' => 'PhabricatorOAuthClientBaseController', - 'PhabricatorOAuthClientEditController' => 'PhabricatorOAuthClientBaseController', - 'PhabricatorOAuthClientListController' => 'PhabricatorOAuthClientBaseController', - 'PhabricatorOAuthClientViewController' => 'PhabricatorOAuthClientBaseController', + 'PhabricatorOAuthClientController' => 'PhabricatorOAuthServerController', + 'PhabricatorOAuthClientDeleteController' => 'PhabricatorOAuthClientController', + 'PhabricatorOAuthClientEditController' => 'PhabricatorOAuthClientController', + 'PhabricatorOAuthClientListController' => 'PhabricatorOAuthClientController', + 'PhabricatorOAuthClientViewController' => 'PhabricatorOAuthClientController', 'PhabricatorOAuthResponse' => 'AphrontResponse', 'PhabricatorOAuthServerAccessToken' => 'PhabricatorOAuthServerDAO', 'PhabricatorOAuthServerAuthController' => 'PhabricatorAuthController', diff --git a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientBaseController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientController.php similarity index 93% rename from src/applications/oauthserver/controller/client/PhabricatorOAuthClientBaseController.php rename to src/applications/oauthserver/controller/client/PhabricatorOAuthClientController.php index 90cdb525d4..c373738b1a 100644 --- a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientBaseController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientController.php @@ -1,6 +1,6 @@ getRequest(); diff --git a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php index 0de4776230..9ed97d85f5 100644 --- a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientEditController.php @@ -1,7 +1,7 @@ getRequest(); diff --git a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php index 230a1d47b0..ee5d85661a 100644 --- a/src/applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php +++ b/src/applications/oauthserver/controller/client/PhabricatorOAuthClientListController.php @@ -1,7 +1,7 @@ getRequest(); From 254542237a66ac1d7fedc39c71d26575f641c31b Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 22 Jul 2014 00:38:23 +1000 Subject: [PATCH 42/44] Simplify the implementation of `PhabricatorPHIDType` subclasses Summary: Instead of implementing the `getTypeConstant` method in all subclasses of `PhabricatorPHIDType`, provide a `final` implementation in the base class which uses reflection. See D9837 for a similar implementation. Test Plan: Ran `arc unit`. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin, hach-que Differential Revision: https://secure.phabricator.com/D9985 --- .../PhabricatorAuthPHIDTypeAuthFactor.php | 4 ---- .../phid/PhabricatorCalendarPHIDTypeEvent.php | 4 ---- .../phid/PhabricatorConfigPHIDTypeConfig.php | 4 ---- .../PhabricatorConpherencePHIDTypeThread.php | 4 ---- .../PhabricatorCountdownPHIDTypeCountdown.php | 4 ---- .../PhabricatorDashboardPHIDTypeDashboard.php | 4 ---- .../PhabricatorDashboardPHIDTypePanel.php | 4 ---- .../phid/DifferentialPHIDTypeDiff.php | 4 ---- .../phid/DifferentialPHIDTypeRevision.php | 4 ---- .../diviner/phid/DivinerPHIDTypeAtom.php | 4 ---- .../diviner/phid/DivinerPHIDTypeBook.php | 4 ---- .../drydock/phid/DrydockPHIDTypeBlueprint.php | 4 ---- .../drydock/phid/DrydockPHIDTypeLease.php | 4 ---- .../drydock/phid/DrydockPHIDTypeResource.php | 4 ---- .../phid/PhabricatorFilePHIDTypeFile.php | 4 ---- .../phid/HarbormasterPHIDTypeBuild.php | 4 ---- .../phid/HarbormasterPHIDTypeBuildItem.php | 4 ---- .../phid/HarbormasterPHIDTypeBuildLog.php | 4 ---- .../phid/HarbormasterPHIDTypeBuildPlan.php | 4 ---- .../phid/HarbormasterPHIDTypeBuildStep.php | 4 ---- .../phid/HarbormasterPHIDTypeBuildTarget.php | 4 ---- .../phid/HarbormasterPHIDTypeBuildable.php | 4 ---- .../herald/phid/HeraldPHIDTypeRule.php | 4 ---- .../PhabricatorLegalpadPHIDTypeDocument.php | 4 ---- .../phid/PhabricatorMacroPHIDTypeMacro.php | 4 ---- .../PhabricatorMailingListPHIDTypeList.php | 4 ---- .../maniphest/phid/ManiphestPHIDTypeTask.php | 4 ---- ...bricatorApplicationPHIDTypeApplication.php | 4 ---- .../nuance/phid/NuancePHIDTypeItem.php | 7 +----- .../nuance/phid/NuancePHIDTypeQueue.php | 4 ---- .../nuance/phid/NuancePHIDTypeRequestor.php | 7 +----- .../nuance/phid/NuancePHIDTypeSource.php | 7 +----- .../PhabricatorOAuthServerPHIDTypeClient.php | 4 ---- ...OAuthServerPHIDTypeClientAuthorization.php | 4 ---- .../phid/PhabricatorOwnersPHIDTypePackage.php | 4 ---- .../phid/PassphrasePHIDTypeCredential.php | 4 ---- .../phid/PhabricatorPastePHIDTypePaste.php | 4 ---- .../PhabricatorPeoplePHIDTypeExternal.php | 4 ---- .../phid/PhabricatorPeoplePHIDTypeUser.php | 4 ---- .../phid/PhabricatorPhamePHIDTypeBlog.php | 4 ---- .../phid/PhabricatorPhamePHIDTypePost.php | 4 ---- .../phid/type/PhabricatorPHIDType.php | 23 ++++++++++++++++++- .../phlux/phid/PhluxPHIDTypeVariable.php | 4 ---- .../pholio/phid/PholioPHIDTypeImage.php | 4 ---- .../pholio/phid/PholioPHIDTypeMock.php | 4 ---- .../phid/PhragmentPHIDTypeFragment.php | 7 +----- .../phid/PhragmentPHIDTypeFragmentVersion.php | 7 +----- .../phid/PhragmentPHIDTypeSnapshot.php | 7 +----- .../phid/PhrictionPHIDTypeDocument.php | 4 ---- .../phid/PhabricatorPolicyPHIDTypePolicy.php | 7 +----- .../ponder/phid/PonderPHIDTypeAnswer.php | 4 ---- .../ponder/phid/PonderPHIDTypeQuestion.php | 4 ---- .../phid/PhabricatorProjectPHIDTypeColumn.php | 4 ---- .../PhabricatorProjectPHIDTypeProject.php | 4 ---- .../releeph/phid/ReleephPHIDTypeBranch.php | 4 ---- .../releeph/phid/ReleephPHIDTypeProduct.php | 4 ---- .../releeph/phid/ReleephPHIDTypeRequest.php | 4 ---- ...catorRepositoryPHIDTypeArcanistProject.php | 4 ---- .../PhabricatorRepositoryPHIDTypeCommit.php | 4 ---- .../PhabricatorRepositoryPHIDTypeMirror.php | 7 +----- ...PhabricatorRepositoryPHIDTypePushEvent.php | 7 +----- .../PhabricatorRepositoryPHIDTypePushLog.php | 7 +----- ...habricatorRepositoryPHIDTypeRepository.php | 4 ---- .../phid/PhabricatorSlowvotePHIDTypePoll.php | 4 ---- .../phid/PhabricatorTokenPHIDTypeToken.php | 4 ---- ...licationTransactionPHIDTypeTransaction.php | 4 ---- 66 files changed, 32 insertions(+), 281 deletions(-) diff --git a/src/applications/auth/phid/PhabricatorAuthPHIDTypeAuthFactor.php b/src/applications/auth/phid/PhabricatorAuthPHIDTypeAuthFactor.php index 181882dcdd..58d239a7ea 100644 --- a/src/applications/auth/phid/PhabricatorAuthPHIDTypeAuthFactor.php +++ b/src/applications/auth/phid/PhabricatorAuthPHIDTypeAuthFactor.php @@ -4,10 +4,6 @@ final class PhabricatorAuthPHIDTypeAuthFactor extends PhabricatorPHIDType { const TYPECONST = 'AFTR'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Auth Factor'); } diff --git a/src/applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php b/src/applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php index 0fb7c9d086..a87eafba29 100644 --- a/src/applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php +++ b/src/applications/calendar/phid/PhabricatorCalendarPHIDTypeEvent.php @@ -4,10 +4,6 @@ final class PhabricatorCalendarPHIDTypeEvent extends PhabricatorPHIDType { const TYPECONST = 'CEVT'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Event'); } diff --git a/src/applications/config/phid/PhabricatorConfigPHIDTypeConfig.php b/src/applications/config/phid/PhabricatorConfigPHIDTypeConfig.php index 5742a7e9e5..793b63955a 100644 --- a/src/applications/config/phid/PhabricatorConfigPHIDTypeConfig.php +++ b/src/applications/config/phid/PhabricatorConfigPHIDTypeConfig.php @@ -4,10 +4,6 @@ final class PhabricatorConfigPHIDTypeConfig extends PhabricatorPHIDType { const TYPECONST = 'CONF'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Config'); } diff --git a/src/applications/conpherence/phid/PhabricatorConpherencePHIDTypeThread.php b/src/applications/conpherence/phid/PhabricatorConpherencePHIDTypeThread.php index 3a6319a954..d644774b5b 100644 --- a/src/applications/conpherence/phid/PhabricatorConpherencePHIDTypeThread.php +++ b/src/applications/conpherence/phid/PhabricatorConpherencePHIDTypeThread.php @@ -4,10 +4,6 @@ final class PhabricatorConpherencePHIDTypeThread extends PhabricatorPHIDType { const TYPECONST = 'CONP'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Conpherence Thread'); } diff --git a/src/applications/countdown/phid/PhabricatorCountdownPHIDTypeCountdown.php b/src/applications/countdown/phid/PhabricatorCountdownPHIDTypeCountdown.php index ef60213d36..b859f80d5a 100644 --- a/src/applications/countdown/phid/PhabricatorCountdownPHIDTypeCountdown.php +++ b/src/applications/countdown/phid/PhabricatorCountdownPHIDTypeCountdown.php @@ -4,10 +4,6 @@ final class PhabricatorCountdownPHIDTypeCountdown extends PhabricatorPHIDType { const TYPECONST = 'CDWN'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Countdown'); } diff --git a/src/applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php b/src/applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php index 0af0fd3d9d..67a27a892c 100644 --- a/src/applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php +++ b/src/applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php @@ -4,10 +4,6 @@ final class PhabricatorDashboardPHIDTypeDashboard extends PhabricatorPHIDType { const TYPECONST = 'DSHB'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Dashboard'); } diff --git a/src/applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php b/src/applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php index 882f728c1e..ec552a242b 100644 --- a/src/applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php +++ b/src/applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php @@ -4,10 +4,6 @@ final class PhabricatorDashboardPHIDTypePanel extends PhabricatorPHIDType { const TYPECONST = 'DSHP'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Panel'); } diff --git a/src/applications/differential/phid/DifferentialPHIDTypeDiff.php b/src/applications/differential/phid/DifferentialPHIDTypeDiff.php index dda8b61b94..c5f6e44dc9 100644 --- a/src/applications/differential/phid/DifferentialPHIDTypeDiff.php +++ b/src/applications/differential/phid/DifferentialPHIDTypeDiff.php @@ -4,10 +4,6 @@ final class DifferentialPHIDTypeDiff extends PhabricatorPHIDType { const TYPECONST = 'DIFF'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Differential Diff'); } diff --git a/src/applications/differential/phid/DifferentialPHIDTypeRevision.php b/src/applications/differential/phid/DifferentialPHIDTypeRevision.php index 50a5f42cc4..1cf0154bf5 100644 --- a/src/applications/differential/phid/DifferentialPHIDTypeRevision.php +++ b/src/applications/differential/phid/DifferentialPHIDTypeRevision.php @@ -4,10 +4,6 @@ final class DifferentialPHIDTypeRevision extends PhabricatorPHIDType { const TYPECONST = 'DREV'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Revision'); } diff --git a/src/applications/diviner/phid/DivinerPHIDTypeAtom.php b/src/applications/diviner/phid/DivinerPHIDTypeAtom.php index 6a057c0741..a47efb322b 100644 --- a/src/applications/diviner/phid/DivinerPHIDTypeAtom.php +++ b/src/applications/diviner/phid/DivinerPHIDTypeAtom.php @@ -4,10 +4,6 @@ final class DivinerPHIDTypeAtom extends PhabricatorPHIDType { const TYPECONST = 'ATOM'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Atom'); } diff --git a/src/applications/diviner/phid/DivinerPHIDTypeBook.php b/src/applications/diviner/phid/DivinerPHIDTypeBook.php index 3bd965ee78..af2ebb11e0 100644 --- a/src/applications/diviner/phid/DivinerPHIDTypeBook.php +++ b/src/applications/diviner/phid/DivinerPHIDTypeBook.php @@ -4,10 +4,6 @@ final class DivinerPHIDTypeBook extends PhabricatorPHIDType { const TYPECONST = 'BOOK'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Book'); } diff --git a/src/applications/drydock/phid/DrydockPHIDTypeBlueprint.php b/src/applications/drydock/phid/DrydockPHIDTypeBlueprint.php index 22b074285e..553205cf77 100644 --- a/src/applications/drydock/phid/DrydockPHIDTypeBlueprint.php +++ b/src/applications/drydock/phid/DrydockPHIDTypeBlueprint.php @@ -4,10 +4,6 @@ final class DrydockPHIDTypeBlueprint extends PhabricatorPHIDType { const TYPECONST = 'DRYB'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Blueprint'); } diff --git a/src/applications/drydock/phid/DrydockPHIDTypeLease.php b/src/applications/drydock/phid/DrydockPHIDTypeLease.php index f3f34be0c7..55649c9d92 100644 --- a/src/applications/drydock/phid/DrydockPHIDTypeLease.php +++ b/src/applications/drydock/phid/DrydockPHIDTypeLease.php @@ -4,10 +4,6 @@ final class DrydockPHIDTypeLease extends PhabricatorPHIDType { const TYPECONST = 'DRYL'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Drydock Lease'); } diff --git a/src/applications/drydock/phid/DrydockPHIDTypeResource.php b/src/applications/drydock/phid/DrydockPHIDTypeResource.php index f6bc00f689..ffe76c6e7a 100644 --- a/src/applications/drydock/phid/DrydockPHIDTypeResource.php +++ b/src/applications/drydock/phid/DrydockPHIDTypeResource.php @@ -4,10 +4,6 @@ final class DrydockPHIDTypeResource extends PhabricatorPHIDType { const TYPECONST = 'DRYR'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Drydock Resource'); } diff --git a/src/applications/files/phid/PhabricatorFilePHIDTypeFile.php b/src/applications/files/phid/PhabricatorFilePHIDTypeFile.php index 1f6fe80df6..d655511a31 100644 --- a/src/applications/files/phid/PhabricatorFilePHIDTypeFile.php +++ b/src/applications/files/phid/PhabricatorFilePHIDTypeFile.php @@ -4,10 +4,6 @@ final class PhabricatorFilePHIDTypeFile extends PhabricatorPHIDType { const TYPECONST = 'FILE'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('File'); } diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php index 22f0c8bb62..0977134c7a 100644 --- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php +++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuild.php @@ -4,10 +4,6 @@ final class HarbormasterPHIDTypeBuild extends PhabricatorPHIDType { const TYPECONST = 'HMBD'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Build'); } diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildItem.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildItem.php index 4d6fdb1982..83603ec079 100644 --- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildItem.php +++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildItem.php @@ -4,10 +4,6 @@ final class HarbormasterPHIDTypeBuildItem extends PhabricatorPHIDType { const TYPECONST = 'HMBI'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Build Item'); } diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildLog.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildLog.php index 385cbcaac6..2612d15556 100644 --- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildLog.php +++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildLog.php @@ -4,10 +4,6 @@ final class HarbormasterPHIDTypeBuildLog extends PhabricatorPHIDType { const TYPECONST = 'HMCL'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Build Log'); } diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php index d5abaf8f0b..4449974422 100644 --- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php +++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildPlan.php @@ -4,10 +4,6 @@ final class HarbormasterPHIDTypeBuildPlan extends PhabricatorPHIDType { const TYPECONST = 'HMCP'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Build Plan'); } diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildStep.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildStep.php index 3081f32e89..37500a0e73 100644 --- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildStep.php +++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildStep.php @@ -4,10 +4,6 @@ final class HarbormasterPHIDTypeBuildStep extends PhabricatorPHIDType { const TYPECONST = 'HMCS'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Build Step'); } diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildTarget.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildTarget.php index 7f893b77b7..fab5a58239 100644 --- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildTarget.php +++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildTarget.php @@ -4,10 +4,6 @@ final class HarbormasterPHIDTypeBuildTarget extends PhabricatorPHIDType { const TYPECONST = 'HMBT'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Build Target'); } diff --git a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildable.php b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildable.php index 6b05ec6d50..d88dfcfc5c 100644 --- a/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildable.php +++ b/src/applications/harbormaster/phid/HarbormasterPHIDTypeBuildable.php @@ -4,10 +4,6 @@ final class HarbormasterPHIDTypeBuildable extends PhabricatorPHIDType { const TYPECONST = 'HMBB'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Buildable'); } diff --git a/src/applications/herald/phid/HeraldPHIDTypeRule.php b/src/applications/herald/phid/HeraldPHIDTypeRule.php index 62b05c696d..3db09494dd 100644 --- a/src/applications/herald/phid/HeraldPHIDTypeRule.php +++ b/src/applications/herald/phid/HeraldPHIDTypeRule.php @@ -4,10 +4,6 @@ final class HeraldPHIDTypeRule extends PhabricatorPHIDType { const TYPECONST = 'HRUL'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Herald Rule'); } diff --git a/src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php b/src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php index 58cdc582fc..f187ee335f 100644 --- a/src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php +++ b/src/applications/legalpad/phid/PhabricatorLegalpadPHIDTypeDocument.php @@ -4,10 +4,6 @@ final class PhabricatorLegalpadPHIDTypeDocument extends PhabricatorPHIDType { const TYPECONST = 'LEGD'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Legalpad Document'); } diff --git a/src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php b/src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php index 3c9aeb3ea0..9c883b77ab 100644 --- a/src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php +++ b/src/applications/macro/phid/PhabricatorMacroPHIDTypeMacro.php @@ -4,10 +4,6 @@ final class PhabricatorMacroPHIDTypeMacro extends PhabricatorPHIDType { const TYPECONST = 'MCRO'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Image Macro'); } diff --git a/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php b/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php index 3371d2cf0f..6f0c0de0fb 100644 --- a/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php +++ b/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php @@ -4,10 +4,6 @@ final class PhabricatorMailingListPHIDTypeList extends PhabricatorPHIDType { const TYPECONST = 'MLST'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Mailing List'); } diff --git a/src/applications/maniphest/phid/ManiphestPHIDTypeTask.php b/src/applications/maniphest/phid/ManiphestPHIDTypeTask.php index 732ac82260..093c6aa388 100644 --- a/src/applications/maniphest/phid/ManiphestPHIDTypeTask.php +++ b/src/applications/maniphest/phid/ManiphestPHIDTypeTask.php @@ -4,10 +4,6 @@ final class ManiphestPHIDTypeTask extends PhabricatorPHIDType { const TYPECONST = 'TASK'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Task'); } diff --git a/src/applications/meta/phid/PhabricatorApplicationPHIDTypeApplication.php b/src/applications/meta/phid/PhabricatorApplicationPHIDTypeApplication.php index 6ce6c27c6c..d35e43e6e8 100644 --- a/src/applications/meta/phid/PhabricatorApplicationPHIDTypeApplication.php +++ b/src/applications/meta/phid/PhabricatorApplicationPHIDTypeApplication.php @@ -5,10 +5,6 @@ final class PhabricatorApplicationPHIDTypeApplication const TYPECONST = 'APPS'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Application'); } diff --git a/src/applications/nuance/phid/NuancePHIDTypeItem.php b/src/applications/nuance/phid/NuancePHIDTypeItem.php index 41008847fd..79238343c8 100644 --- a/src/applications/nuance/phid/NuancePHIDTypeItem.php +++ b/src/applications/nuance/phid/NuancePHIDTypeItem.php @@ -1,14 +1,9 @@ getConstant('TYPECONST'); + if ($const === false) { + throw new Exception( + pht( + 'PHIDType class "%s" must define an TYPECONST property.', + get_class($this))); + } + + if (!is_string($const) || !preg_match('/^[A-Z]{4}$/', $const)) { + throw new Exception( + pht( + 'PHIDType class "%s" has an invalid TYPECONST property. PHID '. + 'constants must be a four character uppercase string.', + get_class($this))); + } + + return $const; + } + abstract public function getTypeName(); public function newObject() { diff --git a/src/applications/phlux/phid/PhluxPHIDTypeVariable.php b/src/applications/phlux/phid/PhluxPHIDTypeVariable.php index 165bc6d6e7..dc61151b86 100644 --- a/src/applications/phlux/phid/PhluxPHIDTypeVariable.php +++ b/src/applications/phlux/phid/PhluxPHIDTypeVariable.php @@ -4,10 +4,6 @@ final class PhluxPHIDTypeVariable extends PhabricatorPHIDType { const TYPECONST = 'PVAR'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Variable'); } diff --git a/src/applications/pholio/phid/PholioPHIDTypeImage.php b/src/applications/pholio/phid/PholioPHIDTypeImage.php index 54b806cc21..0df43956fc 100644 --- a/src/applications/pholio/phid/PholioPHIDTypeImage.php +++ b/src/applications/pholio/phid/PholioPHIDTypeImage.php @@ -4,10 +4,6 @@ final class PholioPHIDTypeImage extends PhabricatorPHIDType { const TYPECONST = 'PIMG'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Image'); } diff --git a/src/applications/pholio/phid/PholioPHIDTypeMock.php b/src/applications/pholio/phid/PholioPHIDTypeMock.php index 39025fcfd8..0cd08c8e68 100644 --- a/src/applications/pholio/phid/PholioPHIDTypeMock.php +++ b/src/applications/pholio/phid/PholioPHIDTypeMock.php @@ -4,10 +4,6 @@ final class PholioPHIDTypeMock extends PhabricatorPHIDType { const TYPECONST = 'MOCK'; - public function getTypeConstant() { - return self::TYPECONST; - } - public function getTypeName() { return pht('Mock'); } diff --git a/src/applications/phragment/phid/PhragmentPHIDTypeFragment.php b/src/applications/phragment/phid/PhragmentPHIDTypeFragment.php index 0a5484911e..2b26e6717c 100644 --- a/src/applications/phragment/phid/PhragmentPHIDTypeFragment.php +++ b/src/applications/phragment/phid/PhragmentPHIDTypeFragment.php @@ -1,14 +1,9 @@ Date: Tue, 22 Jul 2014 01:47:00 +1000 Subject: [PATCH 43/44] Utilize `PhutilMethodNotImplementedException` Summary: Depends on D9992. Utilize the `PhutilMethodNotImplementedException` class. Test Plan: N/A Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D10000 --- .../auth/provider/PhabricatorAuthProvider.php | 4 ++-- .../render/DifferentialChangesetOneUpRenderer.php | 12 +++++++----- .../render/DifferentialChangesetTestRenderer.php | 12 +++++++----- src/applications/phid/type/PhabricatorPHIDType.php | 2 +- .../engine/PhabricatorApplicationSearchEngine.php | 2 +- .../PhabricatorApplicationTransactionEditor.php | 2 +- .../storage/PhabricatorApplicationTransaction.php | 2 +- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/applications/auth/provider/PhabricatorAuthProvider.php b/src/applications/auth/provider/PhabricatorAuthProvider.php index 0381f4822a..bc381ad636 100644 --- a/src/applications/auth/provider/PhabricatorAuthProvider.php +++ b/src/applications/auth/provider/PhabricatorAuthProvider.php @@ -180,7 +180,7 @@ abstract class PhabricatorAuthProvider { protected function renderLoginForm( AphrontRequest $request, $mode) { - throw new Exception('Not implemented!'); + throw new PhutilMethodNotImplementedException(); } public function createProviders() { @@ -295,7 +295,7 @@ abstract class PhabricatorAuthProvider { } public function getDefaultExternalAccount() { - throw new Exception('Not implemented!'); + throw new PhutilMethodNotImplementedException(); } public function getLoginOrder() { diff --git a/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php b/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php index ac3c2a7d1a..b214f74c5f 100644 --- a/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetOneUpRenderer.php @@ -67,11 +67,13 @@ final class DifferentialChangesetOneUpRenderer return null; } - public function renderFileChange($old_file = null, - $new_file = null, - $id = 0, - $vs = 0) { - throw new Exception('Not implemented!'); + public function renderFileChange( + $old_file = null, + $new_file = null, + $id = 0, + $vs = 0) { + + throw new PhutilMethodNotImplementedException(); } } diff --git a/src/applications/differential/render/DifferentialChangesetTestRenderer.php b/src/applications/differential/render/DifferentialChangesetTestRenderer.php index 4dd0ff7646..9941c8a6db 100644 --- a/src/applications/differential/render/DifferentialChangesetTestRenderer.php +++ b/src/applications/differential/render/DifferentialChangesetTestRenderer.php @@ -76,11 +76,13 @@ abstract class DifferentialChangesetTestRenderer } - public function renderFileChange($old_file = null, - $new_file = null, - $id = 0, - $vs = 0) { - throw new Exception('Not implemented!'); + public function renderFileChange( + $old_file = null, + $new_file = null, + $id = 0, + $vs = 0) { + + throw new PhutilMethodNotImplementedException(); } } diff --git a/src/applications/phid/type/PhabricatorPHIDType.php b/src/applications/phid/type/PhabricatorPHIDType.php index 035f4214f0..221048f93b 100644 --- a/src/applications/phid/type/PhabricatorPHIDType.php +++ b/src/applications/phid/type/PhabricatorPHIDType.php @@ -135,7 +135,7 @@ abstract class PhabricatorPHIDType { public function loadNamedObjects( PhabricatorObjectQuery $query, array $names) { - throw new Exception('Not implemented!'); + throw new PhutilMethodNotImplementedException(); } diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index c0015494ea..531f88e70d 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -244,7 +244,7 @@ abstract class PhabricatorApplicationSearchEngine { } protected function getApplicationClassName() { - throw new Exception(pht('Not implemented for this SearchEngine yet!')); + throw new PhutilMethodNotImplementedException(); } diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 44a9dc48d5..e532924777 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -327,7 +327,7 @@ abstract class PhabricatorApplicationTransactionEditor protected function applyInitialEffects( PhabricatorLiskDAO $object, array $xactions) { - throw new Exception('Not implemented.'); + throw new PhutilMethodNotImplementedException(); } private function applyInternalEffects( diff --git a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php index a45406e20b..1469bfb6d6 100644 --- a/src/applications/transactions/storage/PhabricatorApplicationTransaction.php +++ b/src/applications/transactions/storage/PhabricatorApplicationTransaction.php @@ -76,7 +76,7 @@ abstract class PhabricatorApplicationTransaction } public function getApplicationTransactionCommentObject() { - throw new Exception('Not implemented!'); + throw new PhutilMethodNotImplementedException(); } public function getApplicationTransactionViewObject() { From 55fed957648c67866e94eca8249304f529d14cb3 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 22 Jul 2014 07:56:27 +1000 Subject: [PATCH 44/44] Change class names in documentation Summary: Ref T5655. Update class names in documentation after D9983. Test Plan: N/A Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5655 Differential Revision: https://secure.phabricator.com/D9984 --- src/docs/user/userguide/arcanist_lint_unit.diviner | 2 +- src/docs/user/userguide/arcanist_new_project.diviner | 2 +- src/docs/user/userguide/events.diviner | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/docs/user/userguide/arcanist_lint_unit.diviner b/src/docs/user/userguide/arcanist_lint_unit.diviner index d9cc107440..3b12de9dac 100644 --- a/src/docs/user/userguide/arcanist_lint_unit.diviner +++ b/src/docs/user/userguide/arcanist_lint_unit.diviner @@ -17,7 +17,7 @@ you need to build new classes. For instance: - if you want to configure linters, or add new linters, you need to create a new class which extends @{class@arcanist:ArcanistLintEngine}. - if you want to integrate with a unit testing framework, you need to create a - new class which extends @{class@arcanist:ArcanistBaseUnitTestEngine}. + new class which extends @{class@arcanist:ArcanistUnitTestEngine}. - if you you want to change how workflows behave, or add new workflows, you need to create a new class which extends @{class@arcanist:ArcanistConfiguration}. diff --git a/src/docs/user/userguide/arcanist_new_project.diviner b/src/docs/user/userguide/arcanist_new_project.diviner index 106ec6f8f8..fbb2ad4a45 100644 --- a/src/docs/user/userguide/arcanist_new_project.diviner +++ b/src/docs/user/userguide/arcanist_new_project.diviner @@ -59,7 +59,7 @@ Other options include: @{class@arcanist:ArcanistLintEngine}, which should be used to apply lint rules to this project. See @{article:Arcanist User Guide: Lint}. - **unit.engine**: the name of a subclass of - @{class@arcanist:ArcanistBaseUnitTestEngine}, which should be used to apply + @{class@arcanist:ArcanistUnitTestEngine}, which should be used to apply unit test rules to this project. See @{article:Arcanist User Guide: Customizing Lint, Unit Tests and Workflows}. diff --git a/src/docs/user/userguide/events.diviner b/src/docs/user/userguide/events.diviner index 0ec3542f3f..3cfa38e3c6 100644 --- a/src/docs/user/userguide/events.diviner +++ b/src/docs/user/userguide/events.diviner @@ -91,7 +91,7 @@ Arcanist event constants are listed in @{class@arcanist:ArcanistEventType}. All Arcanist events have this data available: - - `workflow` The active @{class@arcanist:ArcanistBaseWorkflow}. + - `workflow` The active @{class@arcanist:ArcanistWorkflow}. == Arcanist: Commit: Will Commit SVN ==