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

Add some core phid functions

Summary: As title

Test Plan: hit diffcamp, owners to test HandleData

Reviewers: epriestley, btrahan

CC: aran

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

mkedia be3c1795 5ee1341b

+71 -16
+1 -1
src/applications/flag/query/flag/PhabricatorFlagQuery.php
··· 68 68 return id(new PhabricatorFlag())->loadOneWhere( 69 69 'ownerPHID = %s AND type = %s AND objectPHID = %s', 70 70 $user->getPHID(), 71 - PhabricatorObjectHandleData::lookupType($object_phid), 71 + phid_get_type($object_phid), 72 72 $object_phid); 73 73 } 74 74
+1
src/applications/flag/query/flag/__init__.php
··· 8 8 9 9 phutil_require_module('phabricator', 'applications/flag/storage/flag'); 10 10 phutil_require_module('phabricator', 'applications/phid/handle/data'); 11 + phutil_require_module('phabricator', 'applications/phid/utils'); 11 12 phutil_require_module('phabricator', 'storage/qsprintf'); 12 13 phutil_require_module('phabricator', 'storage/queryfx'); 13 14
+2 -15
src/applications/phid/handle/data/PhabricatorObjectHandleData.php
··· 32 32 public function loadObjects() { 33 33 $types = array(); 34 34 foreach ($this->phids as $phid) { 35 - $type = self::lookupType($phid); 35 + $type = phid_get_type($phid); 36 36 $types[$type][] = $phid; 37 37 } 38 38 ··· 98 98 99 99 public function loadHandles() { 100 100 101 - $types = array(); 102 - foreach ($this->phids as $phid) { 103 - $type = self::lookupType($phid); 104 - $types[$type][] = $phid; 105 - } 101 + $types = phid_group_by_type($this->phids); 106 102 107 103 $handles = array(); 108 104 ··· 497 493 498 494 return $handles; 499 495 } 500 - 501 - public static function lookupType($phid) { 502 - $matches = null; 503 - if (preg_match('/^PHID-([^-]{4})-/', $phid, $matches)) { 504 - return $matches[1]; 505 - } 506 - return PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN; 507 - } 508 - 509 496 }
+1
src/applications/phid/handle/data/__init__.php
··· 14 14 phutil_require_module('phabricator', 'applications/phid/constants'); 15 15 phutil_require_module('phabricator', 'applications/phid/handle'); 16 16 phutil_require_module('phabricator', 'applications/phid/handle/const/status'); 17 + phutil_require_module('phabricator', 'applications/phid/utils'); 17 18 phutil_require_module('phabricator', 'applications/phriction/storage/document'); 18 19 phutil_require_module('phabricator', 'applications/repository/constants/repositorytype'); 19 20 phutil_require_module('phabricator', 'applications/repository/storage/repository');
+12
src/applications/phid/utils/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/phid/constants'); 10 + 11 + 12 + phutil_require_source('utils.php');
+54
src/applications/phid/utils/utils.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + /** 20 + * Look up the type of a PHID. Returns 21 + * PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN if it fails to look up the type 22 + * 23 + * @param phid Anything. 24 + * @return A value from PhabricatorPHIDConstants (ideally) 25 + */ 26 + function phid_get_type($phid) { 27 + $matches = null; 28 + if (is_string($phid) && preg_match('/^PHID-([^-]{4})-/', $phid, $matches)) { 29 + return $matches[1]; 30 + } 31 + return PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN; 32 + } 33 + 34 + /** 35 + * Group a list of phids by type. Given: 36 + * 37 + * phid_group_by_type([PHID-USER-1, PHID-USER-2, PHID-PROJ-3]) 38 + * 39 + * phid_group_by_type would return: 40 + * 41 + * [PhabricatorPHIDConstants::PHID_TYPE_USER => [PHID-USER-1, PHID-USER-2], 42 + * PhabricatorPHIDConstants::PHID_TYPE_PROJ => [PHID-PROJ-3]] 43 + * 44 + * @param phids array of phids 45 + * @return map of phid type => list of phids 46 + */ 47 + function phid_group_by_type($phids) { 48 + $result = array(); 49 + foreach ($phids as $phid) { 50 + $type = phid_get_type($phid); 51 + $result[$type][] = $phid; 52 + } 53 + return $result; 54 + }