@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement common infrastructure fields as export extensions

Summary:
Depends on D18959. Ref T13049. Provide tags, subscribers, spaces, and created/modified as automatic extensions for all objects which support them.

(Also, for JSON export, be a little more consistent about exporting `null` instead of empty string when there's no value in a text field.)

Test Plan: Exported users and tasks, saw relevant fields in the export.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13049

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

+276 -7
+14
src/__phutil_library_map__.php
··· 3130 3130 'PhabricatorLipsumManagementWorkflow' => 'applications/lipsum/management/PhabricatorLipsumManagementWorkflow.php', 3131 3131 'PhabricatorLipsumMondrianArtist' => 'applications/lipsum/image/PhabricatorLipsumMondrianArtist.php', 3132 3132 'PhabricatorLiskDAO' => 'infrastructure/storage/lisk/PhabricatorLiskDAO.php', 3133 + 'PhabricatorLiskExportEngineExtension' => 'infrastructure/export/engine/PhabricatorLiskExportEngineExtension.php', 3133 3134 'PhabricatorLiskFulltextEngineExtension' => 'applications/search/engineextension/PhabricatorLiskFulltextEngineExtension.php', 3134 3135 'PhabricatorLiskSearchEngineExtension' => 'applications/search/engineextension/PhabricatorLiskSearchEngineExtension.php', 3135 3136 'PhabricatorLiskSerializer' => 'infrastructure/storage/lisk/PhabricatorLiskSerializer.php', 3137 + 'PhabricatorListExportField' => 'infrastructure/export/field/PhabricatorListExportField.php', 3136 3138 'PhabricatorLocalDiskFileStorageEngine' => 'applications/files/engine/PhabricatorLocalDiskFileStorageEngine.php', 3137 3139 'PhabricatorLocalTimeTestCase' => 'view/__tests__/PhabricatorLocalTimeTestCase.php', 3138 3140 'PhabricatorLocaleScopeGuard' => 'infrastructure/internationalization/scope/PhabricatorLocaleScopeGuard.php', ··· 3431 3433 'PhabricatorPHIDInterface' => 'applications/phid/interface/PhabricatorPHIDInterface.php', 3432 3434 'PhabricatorPHIDListEditField' => 'applications/transactions/editfield/PhabricatorPHIDListEditField.php', 3433 3435 'PhabricatorPHIDListEditType' => 'applications/transactions/edittype/PhabricatorPHIDListEditType.php', 3436 + 'PhabricatorPHIDListExportField' => 'infrastructure/export/field/PhabricatorPHIDListExportField.php', 3434 3437 'PhabricatorPHIDResolver' => 'applications/phid/resolver/PhabricatorPHIDResolver.php', 3435 3438 'PhabricatorPHIDType' => 'applications/phid/type/PhabricatorPHIDType.php', 3436 3439 'PhabricatorPHIDTypeTestCase' => 'applications/phid/type/__tests__/PhabricatorPHIDTypeTestCase.php', ··· 3839 3842 'PhabricatorProjectsCurtainExtension' => 'applications/project/engineextension/PhabricatorProjectsCurtainExtension.php', 3840 3843 'PhabricatorProjectsEditEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php', 3841 3844 'PhabricatorProjectsEditField' => 'applications/transactions/editfield/PhabricatorProjectsEditField.php', 3845 + 'PhabricatorProjectsExportEngineExtension' => 'infrastructure/export/engine/PhabricatorProjectsExportEngineExtension.php', 3842 3846 'PhabricatorProjectsFulltextEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsFulltextEngineExtension.php', 3843 3847 'PhabricatorProjectsMembersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsMembersSearchEngineAttachment.php', 3844 3848 'PhabricatorProjectsMembershipIndexEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsMembershipIndexEngineExtension.php', ··· 4130 4134 'PhabricatorSpacesController' => 'applications/spaces/controller/PhabricatorSpacesController.php', 4131 4135 'PhabricatorSpacesDAO' => 'applications/spaces/storage/PhabricatorSpacesDAO.php', 4132 4136 'PhabricatorSpacesEditController' => 'applications/spaces/controller/PhabricatorSpacesEditController.php', 4137 + 'PhabricatorSpacesExportEngineExtension' => 'infrastructure/export/engine/PhabricatorSpacesExportEngineExtension.php', 4133 4138 'PhabricatorSpacesInterface' => 'applications/spaces/interface/PhabricatorSpacesInterface.php', 4134 4139 'PhabricatorSpacesListController' => 'applications/spaces/controller/PhabricatorSpacesListController.php', 4135 4140 'PhabricatorSpacesNamespace' => 'applications/spaces/storage/PhabricatorSpacesNamespace.php', ··· 4196 4201 'PhabricatorStringExportField' => 'infrastructure/export/field/PhabricatorStringExportField.php', 4197 4202 'PhabricatorStringListConfigType' => 'applications/config/type/PhabricatorStringListConfigType.php', 4198 4203 'PhabricatorStringListEditField' => 'applications/transactions/editfield/PhabricatorStringListEditField.php', 4204 + 'PhabricatorStringListExportField' => 'infrastructure/export/field/PhabricatorStringListExportField.php', 4199 4205 'PhabricatorStringSetting' => 'applications/settings/setting/PhabricatorStringSetting.php', 4200 4206 'PhabricatorSubmitEditField' => 'applications/transactions/editfield/PhabricatorSubmitEditField.php', 4201 4207 'PhabricatorSubscribableInterface' => 'applications/subscriptions/interface/PhabricatorSubscribableInterface.php', ··· 4210 4216 'PhabricatorSubscriptionsEditController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php', 4211 4217 'PhabricatorSubscriptionsEditEngineExtension' => 'applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php', 4212 4218 'PhabricatorSubscriptionsEditor' => 'applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php', 4219 + 'PhabricatorSubscriptionsExportEngineExtension' => 'infrastructure/export/engine/PhabricatorSubscriptionsExportEngineExtension.php', 4213 4220 'PhabricatorSubscriptionsFulltextEngineExtension' => 'applications/subscriptions/engineextension/PhabricatorSubscriptionsFulltextEngineExtension.php', 4214 4221 'PhabricatorSubscriptionsHeraldAction' => 'applications/subscriptions/herald/PhabricatorSubscriptionsHeraldAction.php', 4215 4222 'PhabricatorSubscriptionsListController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsListController.php', ··· 8608 8615 'PhabricatorLipsumManagementWorkflow' => 'PhabricatorManagementWorkflow', 8609 8616 'PhabricatorLipsumMondrianArtist' => 'PhabricatorLipsumArtist', 8610 8617 'PhabricatorLiskDAO' => 'LiskDAO', 8618 + 'PhabricatorLiskExportEngineExtension' => 'PhabricatorExportEngineExtension', 8611 8619 'PhabricatorLiskFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension', 8612 8620 'PhabricatorLiskSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 8613 8621 'PhabricatorLiskSerializer' => 'Phobject', 8622 + 'PhabricatorListExportField' => 'PhabricatorExportField', 8614 8623 'PhabricatorLocalDiskFileStorageEngine' => 'PhabricatorFileStorageEngine', 8615 8624 'PhabricatorLocalTimeTestCase' => 'PhabricatorTestCase', 8616 8625 'PhabricatorLocaleScopeGuard' => 'Phobject', ··· 8948 8957 'PhabricatorPHIDExportField' => 'PhabricatorExportField', 8949 8958 'PhabricatorPHIDListEditField' => 'PhabricatorEditField', 8950 8959 'PhabricatorPHIDListEditType' => 'PhabricatorEditType', 8960 + 'PhabricatorPHIDListExportField' => 'PhabricatorListExportField', 8951 8961 'PhabricatorPHIDResolver' => 'Phobject', 8952 8962 'PhabricatorPHIDType' => 'Phobject', 8953 8963 'PhabricatorPHIDTypeTestCase' => 'PhutilTestCase', ··· 9448 9458 'PhabricatorProjectsCurtainExtension' => 'PHUICurtainExtension', 9449 9459 'PhabricatorProjectsEditEngineExtension' => 'PhabricatorEditEngineExtension', 9450 9460 'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField', 9461 + 'PhabricatorProjectsExportEngineExtension' => 'PhabricatorExportEngineExtension', 9451 9462 'PhabricatorProjectsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension', 9452 9463 'PhabricatorProjectsMembersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 9453 9464 'PhabricatorProjectsMembershipIndexEngineExtension' => 'PhabricatorIndexEngineExtension', ··· 9815 9826 'PhabricatorSpacesController' => 'PhabricatorController', 9816 9827 'PhabricatorSpacesDAO' => 'PhabricatorLiskDAO', 9817 9828 'PhabricatorSpacesEditController' => 'PhabricatorSpacesController', 9829 + 'PhabricatorSpacesExportEngineExtension' => 'PhabricatorExportEngineExtension', 9818 9830 'PhabricatorSpacesInterface' => 'PhabricatorPHIDInterface', 9819 9831 'PhabricatorSpacesListController' => 'PhabricatorSpacesController', 9820 9832 'PhabricatorSpacesNamespace' => array( ··· 9888 9900 'PhabricatorStringExportField' => 'PhabricatorExportField', 9889 9901 'PhabricatorStringListConfigType' => 'PhabricatorTextListConfigType', 9890 9902 'PhabricatorStringListEditField' => 'PhabricatorEditField', 9903 + 'PhabricatorStringListExportField' => 'PhabricatorListExportField', 9891 9904 'PhabricatorStringSetting' => 'PhabricatorSetting', 9892 9905 'PhabricatorSubmitEditField' => 'PhabricatorEditField', 9893 9906 'PhabricatorSubscribedToObjectEdgeType' => 'PhabricatorEdgeType', ··· 9901 9914 'PhabricatorSubscriptionsEditController' => 'PhabricatorController', 9902 9915 'PhabricatorSubscriptionsEditEngineExtension' => 'PhabricatorEditEngineExtension', 9903 9916 'PhabricatorSubscriptionsEditor' => 'PhabricatorEditor', 9917 + 'PhabricatorSubscriptionsExportEngineExtension' => 'PhabricatorExportEngineExtension', 9904 9918 'PhabricatorSubscriptionsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension', 9905 9919 'PhabricatorSubscriptionsHeraldAction' => 'HeraldAction', 9906 9920 'PhabricatorSubscriptionsListController' => 'PhabricatorController',
+1 -1
src/applications/maniphest/query/ManiphestTaskSearchEngine.php
··· 464 464 ->setLabel(pht('Priority Name')), 465 465 id(new PhabricatorStringExportField()) 466 466 ->setKey('subtype') 467 - ->setLabel('string'), 467 + ->setLabel('Subtype'), 468 468 id(new PhabricatorURIExportField()) 469 469 ->setKey('uri') 470 470 ->setLabel(pht('URI')),
-4
src/applications/people/query/PhabricatorPeopleSearchEngine.php
··· 328 328 id(new PhabricatorStringExportField()) 329 329 ->setKey('realName') 330 330 ->setLabel(pht('Real Name')), 331 - id(new PhabricatorEpochExportField()) 332 - ->setKey('created') 333 - ->setLabel(pht('Date Created')), 334 331 ); 335 332 } 336 333 ··· 342 339 $export[] = array( 343 340 'username' => $user->getUsername(), 344 341 'realName' => $user->getRealName(), 345 - 'created' => $user->getDateCreated(), 346 342 ); 347 343 } 348 344
+42
src/infrastructure/export/engine/PhabricatorLiskExportEngineExtension.php
··· 1 + <?php 2 + 3 + final class PhabricatorLiskExportEngineExtension 4 + extends PhabricatorExportEngineExtension { 5 + 6 + const EXTENSIONKEY = 'lisk'; 7 + 8 + public function supportsObject($object) { 9 + if (!($object instanceof LiskDAO)) { 10 + return false; 11 + } 12 + 13 + if (!$object->getConfigOption(LiskDAO::CONFIG_TIMESTAMPS)) { 14 + return false; 15 + } 16 + 17 + return true; 18 + } 19 + 20 + public function newExportFields() { 21 + return array( 22 + id(new PhabricatorEpochExportField()) 23 + ->setKey('dateCreated') 24 + ->setLabel(pht('Created')), 25 + id(new PhabricatorEpochExportField()) 26 + ->setKey('dateModified') 27 + ->setLabel(pht('Modified')), 28 + ); 29 + } 30 + 31 + public function newExportData(array $objects) { 32 + $map = array(); 33 + foreach ($objects as $object) { 34 + $map[] = array( 35 + 'dateCreated' => $object->getDateCreated(), 36 + 'dateModified' => $object->getDateModified(), 37 + ); 38 + } 39 + return $map; 40 + } 41 + 42 + }
+60
src/infrastructure/export/engine/PhabricatorProjectsExportEngineExtension.php
··· 1 + <?php 2 + 3 + final class PhabricatorProjectsExportEngineExtension 4 + extends PhabricatorExportEngineExtension { 5 + 6 + const EXTENSIONKEY = 'projects'; 7 + 8 + public function supportsObject($object) { 9 + return ($object instanceof PhabricatorProjectInterface); 10 + } 11 + 12 + public function newExportFields() { 13 + return array( 14 + id(new PhabricatorPHIDListExportField()) 15 + ->setKey('tagPHIDs') 16 + ->setLabel(pht('Tag PHIDs')), 17 + id(new PhabricatorStringListExportField()) 18 + ->setKey('tags') 19 + ->setLabel(pht('Tags')), 20 + ); 21 + } 22 + 23 + public function newExportData(array $objects) { 24 + $viewer = $this->getViewer(); 25 + 26 + $object_phids = mpull($objects, 'getPHID'); 27 + 28 + $projects_query = id(new PhabricatorEdgeQuery()) 29 + ->withSourcePHIDs($object_phids) 30 + ->withEdgeTypes( 31 + array( 32 + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, 33 + )); 34 + $projects_query->execute(); 35 + 36 + $handles = $viewer->loadHandles($projects_query->getDestinationPHIDs()); 37 + 38 + $map = array(); 39 + foreach ($objects as $object) { 40 + $object_phid = $object->getPHID(); 41 + 42 + $project_phids = $projects_query->getDestinationPHIDs( 43 + array($object_phid), 44 + array(PhabricatorProjectObjectHasProjectEdgeType::EDGECONST)); 45 + 46 + $handle_list = $handles->newSublist($project_phids); 47 + $handle_list = iterator_to_array($handle_list); 48 + $handle_names = mpull($handle_list, 'getName'); 49 + $handle_names = array_values($handle_names); 50 + 51 + $map[] = array( 52 + 'tagPHIDs' => $project_phids, 53 + 'tags' => $handle_names, 54 + ); 55 + } 56 + 57 + return $map; 58 + } 59 + 60 + }
+53
src/infrastructure/export/engine/PhabricatorSpacesExportEngineExtension.php
··· 1 + <?php 2 + 3 + final class PhabricatorSpacesExportEngineExtension 4 + extends PhabricatorExportEngineExtension { 5 + 6 + const EXTENSIONKEY = 'spaces'; 7 + 8 + public function supportsObject($object) { 9 + $viewer = $this->getViewer(); 10 + 11 + if (!PhabricatorSpacesNamespaceQuery::getViewerSpacesExist($viewer)) { 12 + return false; 13 + } 14 + 15 + return ($object instanceof PhabricatorSpacesInterface); 16 + } 17 + 18 + public function newExportFields() { 19 + return array( 20 + id(new PhabricatorPHIDExportField()) 21 + ->setKey('spacePHID') 22 + ->setLabel(pht('Space PHID')), 23 + id(new PhabricatorStringExportField()) 24 + ->setKey('space') 25 + ->setLabel(pht('Space')), 26 + ); 27 + } 28 + 29 + public function newExportData(array $objects) { 30 + $viewer = $this->getViewer(); 31 + 32 + $space_phids = array(); 33 + foreach ($objects as $object) { 34 + $space_phids[] = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID( 35 + $object); 36 + } 37 + $handles = $viewer->loadHandles($space_phids); 38 + 39 + $map = array(); 40 + foreach ($objects as $object) { 41 + $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID( 42 + $object); 43 + 44 + $map[] = array( 45 + 'spacePHID' => $space_phid, 46 + 'space' => $handles[$space_phid]->getName(), 47 + ); 48 + } 49 + 50 + return $map; 51 + } 52 + 53 + }
+60
src/infrastructure/export/engine/PhabricatorSubscriptionsExportEngineExtension.php
··· 1 + <?php 2 + 3 + final class PhabricatorSubscriptionsExportEngineExtension 4 + extends PhabricatorExportEngineExtension { 5 + 6 + const EXTENSIONKEY = 'subscriptions'; 7 + 8 + public function supportsObject($object) { 9 + return ($object instanceof PhabricatorSubscribableInterface); 10 + } 11 + 12 + public function newExportFields() { 13 + return array( 14 + id(new PhabricatorPHIDListExportField()) 15 + ->setKey('subscriberPHIDs') 16 + ->setLabel(pht('Subscriber PHIDs')), 17 + id(new PhabricatorStringListExportField()) 18 + ->setKey('subscribers') 19 + ->setLabel(pht('Subscribers')), 20 + ); 21 + } 22 + 23 + public function newExportData(array $objects) { 24 + $viewer = $this->getViewer(); 25 + 26 + $object_phids = mpull($objects, 'getPHID'); 27 + 28 + $projects_query = id(new PhabricatorEdgeQuery()) 29 + ->withSourcePHIDs($object_phids) 30 + ->withEdgeTypes( 31 + array( 32 + PhabricatorObjectHasSubscriberEdgeType::EDGECONST, 33 + )); 34 + $projects_query->execute(); 35 + 36 + $handles = $viewer->loadHandles($projects_query->getDestinationPHIDs()); 37 + 38 + $map = array(); 39 + foreach ($objects as $object) { 40 + $object_phid = $object->getPHID(); 41 + 42 + $project_phids = $projects_query->getDestinationPHIDs( 43 + array($object_phid), 44 + array(PhabricatorObjectHasSubscriberEdgeType::EDGECONST)); 45 + 46 + $handle_list = $handles->newSublist($project_phids); 47 + $handle_list = iterator_to_array($handle_list); 48 + $handle_names = mpull($handle_list, 'getName'); 49 + $handle_names = array_values($handle_names); 50 + 51 + $map[] = array( 52 + 'subscriberPHIDs' => $project_phids, 53 + 'subscribers' => $handle_names, 54 + ); 55 + } 56 + 57 + return $map; 58 + } 59 + 60 + }
+7 -1
src/infrastructure/export/field/PhabricatorExportField.php
··· 25 25 } 26 26 27 27 public function getTextValue($value) { 28 - return (string)$this->getNaturalValue($value); 28 + $natural_value = $this->getNaturalValue($value); 29 + 30 + if ($natural_value === null) { 31 + return null; 32 + } 33 + 34 + return (string)$natural_value; 29 35 } 30 36 31 37 public function getNaturalValue($value) {
+10
src/infrastructure/export/field/PhabricatorListExportField.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorListExportField 4 + extends PhabricatorExportField { 5 + 6 + public function getTextValue($value) { 7 + return implode("\n", $value); 8 + } 9 + 10 + }
+10
src/infrastructure/export/field/PhabricatorPHIDListExportField.php
··· 1 + <?php 2 + 3 + final class PhabricatorPHIDListExportField 4 + extends PhabricatorListExportField { 5 + 6 + public function getCharacterWidth() { 7 + return 32; 8 + } 9 + 10 + }
+15 -1
src/infrastructure/export/field/PhabricatorStringExportField.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorStringExportField 4 - extends PhabricatorExportField {} 4 + extends PhabricatorExportField { 5 + 6 + public function getNaturalValue($value) { 7 + if ($value === null) { 8 + return $value; 9 + } 10 + 11 + if (!strlen($value)) { 12 + return null; 13 + } 14 + 15 + return (string)$value; 16 + } 17 + 18 + }
+4
src/infrastructure/export/field/PhabricatorStringListExportField.php
··· 1 + <?php 2 + 3 + final class PhabricatorStringListExportField 4 + extends PhabricatorListExportField {}