From 2a08a12b69e8770515fe9542037eda7d633945e2 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 2 Mar 2011 15:30:35 -0800 Subject: [PATCH 1/3] Updated diviner config. --- .divinerconfig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.divinerconfig b/.divinerconfig index c765720f12..88c73c168f 100644 --- a/.divinerconfig +++ b/.divinerconfig @@ -14,6 +14,10 @@ "aphront" : "Aphront (Web Stack)", "console" : "DarkConsole (Debugging Console)", "storage" : "Storage" - } + }, + "engines" : [ + ["DivinerArticleEngine", {}], + ["DivinerXHPEngine", {}] + ] } From 6439cd98564a1825ca2925cff57b750af4c0006d Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 2 Mar 2011 17:20:54 -0800 Subject: [PATCH 2/3] Revert HipHop volatile symbol workaround. --- .../base/AphrontDatabaseConnection.php | 10 ++-------- src/storage/queryfx/queryfx.php | 16 +++++----------- webroot/index.php | 9 --------- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/storage/connection/base/AphrontDatabaseConnection.php b/src/storage/connection/base/AphrontDatabaseConnection.php index 150f43b960..5d7fd27e27 100644 --- a/src/storage/connection/base/AphrontDatabaseConnection.php +++ b/src/storage/connection/base/AphrontDatabaseConnection.php @@ -36,21 +36,15 @@ abstract class AphrontDatabaseConnection { abstract public function escapeStringForLikeClause($string); public function queryData($pattern/*, $arg, $arg, ... */) { - if (false) { - // Workaround for the HPHP workaround: ensure we include this module - // since we really are using the function. - queryfx($this, $pattern); - } - $args = func_get_args(); array_unshift($args, $this); - return hphp_workaround_call_user_func_array('queryfx_all', $args); + return call_user_func_array('queryfx_all', $args); } public function query($pattern/*, $arg, $arg, ... */) { $args = func_get_args(); array_unshift($args, $this); - return hphp_workaround_call_user_func_array('queryfx', $args); + return call_user_func_array('queryfx', $args); } // TODO: Probably need to reset these when we catch a connection exception diff --git a/src/storage/queryfx/queryfx.php b/src/storage/queryfx/queryfx.php index 91cb5bb376..6195d9c88e 100644 --- a/src/storage/queryfx/queryfx.php +++ b/src/storage/queryfx/queryfx.php @@ -20,14 +20,8 @@ * @group storage */ function queryfx(AphrontDatabaseConnection $conn, $sql/*, ... */) { - if (false) { - // Workaround for the HPHP workaround: ensure we include this module - // since we really are using the function. - qsprintf($conn, $sql); - } - $argv = func_get_args(); - $query = hphp_workaround_call_user_func_array('qsprintf', $argv); + $query = call_user_func_array('qsprintf', $argv); $conn->executeRawQuery($query); } @@ -36,7 +30,7 @@ function queryfx(AphrontDatabaseConnection $conn, $sql/*, ... */) { */ function vqueryfx($conn, $sql, $argv) { array_unshift($argv, $conn, $sql); - hphp_workaround_call_user_func_array('queryfx', $argv); + call_user_func_array('queryfx', $argv); } /** @@ -44,7 +38,7 @@ function vqueryfx($conn, $sql, $argv) { */ function queryfx_all($conn, $sql/*, ... */) { $argv = func_get_args(); - hphp_workaround_call_user_func_array('queryfx', $argv); + call_user_func_array('queryfx', $argv); return $conn->selectAllResults(); } @@ -53,7 +47,7 @@ function queryfx_all($conn, $sql/*, ... */) { */ function queryfx_one($conn, $sql/*, ... */) { $argv = func_get_args(); - $ret = hphp_workaround_call_user_func_array('queryfx_all', $argv); + $ret = call_user_func_array('queryfx_all', $argv); if (count($ret) > 1) { throw new AphrontQueryCountException( 'Query returned more than one row.'); @@ -65,6 +59,6 @@ function queryfx_one($conn, $sql/*, ... */) { function vqueryfx_all($conn, $sql, array $argv) { array_unshift($argv, $conn, $sql); - hphp_workaround_call_user_func_array('queryfx', $argv); + call_user_func_array('queryfx', $argv); return $conn->selectAllResults(); } diff --git a/webroot/index.php b/webroot/index.php index 37e22d8f3f..9960f30c71 100644 --- a/webroot/index.php +++ b/webroot/index.php @@ -176,12 +176,3 @@ function phabricator_fatal_config_error($msg) { die(); } - -/** - * Workaround for HipHop bug, see Facebook Task #503624. - */ -function hphp_workaround_call_user_func_array($func, array $array) { - $f = new ReflectionFunction($func); - return $f->invokeArgs($array); -} - From 9bc04fe03dfea3f89f44d2dc611cbe2c982957aa Mon Sep 17 00:00:00 2001 From: jungejason Date: Wed, 2 Mar 2011 18:58:21 -0800 Subject: [PATCH 3/3] Change hard-coded PHID types to constants. Summary: add a constants module src/applications/phid/constants/PhabricatorPHIDConstants. Test Plan: Execute applications which were using the hard-coded string. Differential Revision: 44 Reviewed By: epriestley Reviewers: epriestley CC: epriestley --- src/__phutil_library_map__.php | 1 + .../attach/DifferentialAttachController.php | 17 ++++++----- .../controller/attach/__init__.php | 1 + .../DifferentialRevisionViewController.php | 3 +- .../controller/revisionview/__init__.php | 1 + .../storage/revision/DifferentialRevision.php | 3 +- .../storage/revision/__init__.php | 1 + .../files/storage/file/PhabricatorFile.php | 5 ++-- .../files/storage/file/__init__.php | 1 + .../ManiphestTaskDetailController.php | 8 ++--- .../controller/taskdetail/__init__.php | 1 + .../ManiphestTaskSelectorSearchController.php | 2 +- .../taskselectorsearch/__init__.php | 1 + .../ManiphestTransactionSaveController.php | 6 ++-- .../controller/transactionsave/__init__.php | 1 + .../maniphest/storage/task/ManiphestTask.php | 3 +- .../maniphest/storage/task/__init__.php | 1 + .../ManiphestTransactionDetailView.php | 7 +++-- .../view/transactiondetail/__init__.php | 1 + .../PhabricatorMetaMTAMailingList.php | 5 ++-- .../metamta/storage/mailinglist/__init__.php | 1 + .../people/storage/user/PhabricatorUser.php | 5 ++-- .../people/storage/user/__init__.php | 1 + .../constants/PhabricatorPHIDConstants.php | 30 +++++++++++++++++++ src/applications/phid/constants/__init__.php | 10 +++++++ .../phid/handle/PhabricatorObjectHandle.php | 2 +- src/applications/phid/handle/__init__.php | 2 ++ .../data/PhabricatorObjectHandleData.php | 18 +++++------ .../phid/handle/data/__init__.php | 1 + .../storage/project/PhabricatorProject.php | 3 +- .../project/storage/project/__init__.php | 1 + .../search/PhabricatorSearchController.php | 4 +-- .../search/controller/search/__init__.php | 1 + .../PhabricatorSearchDifferentialIndexer.php | 10 +++---- .../index/indexer/differential/__init__.php | 1 + .../PhabricatorSearchManiphestIndexer.php | 14 ++++----- .../index/indexer/maniphest/__init__.php | 1 + 37 files changed, 118 insertions(+), 56 deletions(-) create mode 100644 src/applications/phid/constants/PhabricatorPHIDConstants.php create mode 100644 src/applications/phid/constants/__init__.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index a5823a6c62..41383b0a97 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -226,6 +226,7 @@ phutil_register_library_map(array( 'PhabricatorObjectSelectorDialog' => 'view/control/objectselector', 'PhabricatorPHID' => 'applications/phid/storage/phid', 'PhabricatorPHIDAllocateController' => 'applications/phid/controller/allocate', + 'PhabricatorPHIDConstants' => 'applications/phid/constants', 'PhabricatorPHIDController' => 'applications/phid/controller/base', 'PhabricatorPHIDDAO' => 'applications/phid/storage/base', 'PhabricatorPHIDListController' => 'applications/phid/controller/list', diff --git a/src/applications/differential/controller/attach/DifferentialAttachController.php b/src/applications/differential/controller/attach/DifferentialAttachController.php index bfbebc48d5..c578c22098 100644 --- a/src/applications/differential/controller/attach/DifferentialAttachController.php +++ b/src/applications/differential/controller/attach/DifferentialAttachController.php @@ -38,7 +38,8 @@ class DifferentialAttachController extends DifferentialController { if ($request->isFormPost()) { $phids = explode(';', $request->getStr('phids')); - $old_phids = $revision->getAttachedPHIDs('TASK'); + $old_phids = $revision->getAttachedPHIDs( + PhabricatorPHIDConstants::PHID_TYPE_TASK); if (($phids || $old_phids) && ($phids != $old_phids)) { $tasks = id(new ManiphestTask())->loadAllWhere( @@ -59,22 +60,24 @@ class DifferentialAttachController extends DifferentialController { $transaction->setAuthorPHID($user->getPHID()); $transaction->setTransactionType($type); $new = $task->getAttached(); - if (empty($new['DREV'])) { - $new['DREV'] = array(); + if (empty($new[PhabricatorPHIDConstants::PHID_TYPE_DREV])) { + $new[PhabricatorPHIDConstants::PHID_TYPE_DREV] = array(); } $rev_phid = $revision->getPHID(); if (in_array($task->getPHID(), $phids)) { - if (in_array($rev_phid, $task->getAttachedPHIDs('DREV'))) { + if (in_array($rev_phid, $task->getAttachedPHIDs( + PhabricatorPHIDConstants::PHID_TYPE_DREV))) { // TODO: maybe the transaction editor should be responsible for // this? continue; } - $new['DREV'][$rev_phid] = array(); + $new[PhabricatorPHIDConstants::PHID_TYPE_DREV][$rev_phid] = array(); } else { - if (!in_array($rev_phid, $task->getAttachedPHIDs('DREV'))) { + if (!in_array($rev_phid, $task->getAttachedPHIDs( + PhabricatorPHIDConstants::PHID_TYPE_DREV))) { continue; } - unset($new['DREV'][$rev_phid]); + unset($new[PhabricatorPHIDConstants::PHID_TYPE_DREV][$rev_phid]); } $transaction->setNewValue($new); $editor->applyTransactions($task, array($transaction)); diff --git a/src/applications/differential/controller/attach/__init__.php b/src/applications/differential/controller/attach/__init__.php index ec798503d2..ce807b085f 100644 --- a/src/applications/differential/controller/attach/__init__.php +++ b/src/applications/differential/controller/attach/__init__.php @@ -15,6 +15,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/transacti phutil_require_module('phabricator', 'applications/maniphest/editor/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'view/control/objectselector'); diff --git a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php index c08b5e0b31..94c3f7db00 100644 --- a/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php @@ -234,7 +234,8 @@ class DifferentialRevisionViewController extends DifferentialController { $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff); $properties['Unit'] = $ustar.' '.$umsg; - $tasks = $revision->getAttachedPHIDs('TASK'); + $tasks = $revision->getAttachedPHIDs( + PhabricatorPHIDConstants::PHID_TYPE_TASK); if ($tasks) { $links = array(); foreach ($tasks as $task_phid) { diff --git a/src/applications/differential/controller/revisionview/__init__.php b/src/applications/differential/controller/revisionview/__init__.php index 64e62cc7c6..c6e009de3c 100644 --- a/src/applications/differential/controller/revisionview/__init__.php +++ b/src/applications/differential/controller/revisionview/__init__.php @@ -21,6 +21,7 @@ phutil_require_module('phabricator', 'applications/differential/view/revisioncom phutil_require_module('phabricator', 'applications/differential/view/revisiondetail'); phutil_require_module('phabricator', 'applications/differential/view/revisionupdatehistory'); phutil_require_module('phabricator', 'applications/draft/storage/draft'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'view/form/error'); diff --git a/src/applications/differential/storage/revision/DifferentialRevision.php b/src/applications/differential/storage/revision/DifferentialRevision.php index a99c16ec59..047929ebd5 100755 --- a/src/applications/differential/storage/revision/DifferentialRevision.php +++ b/src/applications/differential/storage/revision/DifferentialRevision.php @@ -62,7 +62,8 @@ class DifferentialRevision extends DifferentialDAO { } public function generatePHID() { - return PhabricatorPHID::generateNewPHID('DREV'); + return PhabricatorPHID::generateNewPHID( + PhabricatorPHIDConstants::PHID_TYPE_DREV); } public function loadDiffs() { diff --git a/src/applications/differential/storage/revision/__init__.php b/src/applications/differential/storage/revision/__init__.php index 3720822856..a6690c2650 100644 --- a/src/applications/differential/storage/revision/__init__.php +++ b/src/applications/differential/storage/revision/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'applications/differential/storage/base'); phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/diff'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'storage/queryfx'); diff --git a/src/applications/files/storage/file/PhabricatorFile.php b/src/applications/files/storage/file/PhabricatorFile.php index 84a7d19a63..4a900cdb0f 100644 --- a/src/applications/files/storage/file/PhabricatorFile.php +++ b/src/applications/files/storage/file/PhabricatorFile.php @@ -22,8 +22,6 @@ class PhabricatorFile extends PhabricatorFileDAO { const STORAGE_FORMAT_RAW = 'raw'; - const PHID_TYPE = 'FILE'; - // TODO: We need to reconcile this with MySQL packet size. const FILE_SIZE_BYTE_LIMIT = 12582912; @@ -43,7 +41,8 @@ class PhabricatorFile extends PhabricatorFileDAO { } public function generatePHID() { - return PhabricatorPHID::generateNewPHID(self::PHID_TYPE); + return PhabricatorPHID::generateNewPHID( + PhabricatorPHIDConstants::PHID_TYPE_FILE); } public static function newFromPHPUpload($spec, array $params = array()) { diff --git a/src/applications/files/storage/file/__init__.php b/src/applications/files/storage/file/__init__.php index b15ce974a2..1c82529ee4 100644 --- a/src/applications/files/storage/file/__init__.php +++ b/src/applications/files/storage/file/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'applications/files/storage/base'); phutil_require_module('phabricator', 'applications/files/storage/storageblob'); phutil_require_module('phabricator', 'applications/files/uri'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'infrastructure/env'); diff --git a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php index cf32bfc45c..144d4589f6 100644 --- a/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php +++ b/src/applications/maniphest/controller/taskdetail/ManiphestTaskDetailController.php @@ -107,8 +107,8 @@ class ManiphestTaskDetailController extends ManiphestController { $dict['Projects'] = 'None'; } - if (idx($attached, 'DREV')) { - $revs = idx($attached, 'DREV'); + if (idx($attached, PhabricatorPHIDConstants::PHID_TYPE_DREV)) { + $revs = idx($attached, PhabricatorPHIDConstants::PHID_TYPE_DREV); $rev_links = array(); foreach ($revs as $rev => $info) { $rev_links[] = $handles[$rev]->renderLink(); @@ -117,8 +117,8 @@ class ManiphestTaskDetailController extends ManiphestController { $dict['Revisions'] = $rev_links; } - if (idx($attached, 'FILE')) { - $revs = idx($attached, 'FILE'); + if (idx($attached, PhabricatorPHIDConstants::PHID_TYPE_FILE)) { + $revs = idx($attached, PhabricatorPHIDConstants::PHID_TYPE_FILE); $rev_links = array(); foreach ($revs as $rev => $info) { $rev_links[] = $handles[$rev]->renderLink(); diff --git a/src/applications/maniphest/controller/taskdetail/__init__.php b/src/applications/maniphest/controller/taskdetail/__init__.php index 893586896a..c711ba21b9 100644 --- a/src/applications/maniphest/controller/taskdetail/__init__.php +++ b/src/applications/maniphest/controller/taskdetail/__init__.php @@ -14,6 +14,7 @@ phutil_require_module('phabricator', 'applications/maniphest/controller/base'); phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api'); diff --git a/src/applications/maniphest/controller/taskselectorsearch/ManiphestTaskSelectorSearchController.php b/src/applications/maniphest/controller/taskselectorsearch/ManiphestTaskSelectorSearchController.php index 14a591969a..f547f5e592 100644 --- a/src/applications/maniphest/controller/taskselectorsearch/ManiphestTaskSelectorSearchController.php +++ b/src/applications/maniphest/controller/taskselectorsearch/ManiphestTaskSelectorSearchController.php @@ -24,7 +24,7 @@ class ManiphestTaskSelectorSearchController extends ManiphestController { $query = new PhabricatorSearchQuery(); $query->setQuery($request->getStr('query')); - $query->setParameter('type', 'TASK'); + $query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_TASK); switch ($request->getStr('filter')) { case 'assigned': diff --git a/src/applications/maniphest/controller/taskselectorsearch/__init__.php b/src/applications/maniphest/controller/taskselectorsearch/__init__.php index 63b05f488d..3475c1e17b 100644 --- a/src/applications/maniphest/controller/taskselectorsearch/__init__.php +++ b/src/applications/maniphest/controller/taskselectorsearch/__init__.php @@ -8,6 +8,7 @@ phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'applications/maniphest/controller/base'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/phid/handle/view/selector'); phutil_require_module('phabricator', 'applications/search/execute/mysql'); diff --git a/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php b/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php index 09adbe32de..07762ee649 100644 --- a/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php +++ b/src/applications/maniphest/controller/transactionsave/ManiphestTransactionSaveController.php @@ -76,10 +76,10 @@ class ManiphestTransactionSaveController extends ManiphestController { } if ($phid) { $new = $task->getAttached(); - if (empty($new['FILE'])) { - $new['FILE'] = array(); + if (empty($new[PhabricatorPHIDConstants::PHID_TYPE_FILE])) { + $new[PhabricatorPHIDConstants::PHID_TYPE_FILE] = array(); } - $new['FILE'][$phid] = array(); + $new[PhabricatorPHIDConstants::PHID_TYPE_FILE][$phid] = array(); } $transaction->setNewValue($new); diff --git a/src/applications/maniphest/controller/transactionsave/__init__.php b/src/applications/maniphest/controller/transactionsave/__init__.php index d2a6f38e6d..b7e5685a08 100644 --- a/src/applications/maniphest/controller/transactionsave/__init__.php +++ b/src/applications/maniphest/controller/transactionsave/__init__.php @@ -14,6 +14,7 @@ phutil_require_module('phabricator', 'applications/maniphest/controller/base'); phutil_require_module('phabricator', 'applications/maniphest/editor/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/maniphest/storage/task/ManiphestTask.php b/src/applications/maniphest/storage/task/ManiphestTask.php index 9bf1bb328e..8c8f692429 100644 --- a/src/applications/maniphest/storage/task/ManiphestTask.php +++ b/src/applications/maniphest/storage/task/ManiphestTask.php @@ -48,7 +48,8 @@ class ManiphestTask extends ManiphestDAO { } public function generatePHID() { - return PhabricatorPHID::generateNewPHID('TASK'); + return PhabricatorPHID::generateNewPHID( + PhabricatorPHIDConstants::PHID_TYPE_TASK); } public function getCCPHIDs() { diff --git a/src/applications/maniphest/storage/task/__init__.php b/src/applications/maniphest/storage/task/__init__.php index d8d7b7d38b..95791239e1 100644 --- a/src/applications/maniphest/storage/task/__init__.php +++ b/src/applications/maniphest/storage/task/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'applications/maniphest/storage/base'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php b/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php index a90e0c852c..79f9bb866a 100644 --- a/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php +++ b/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php @@ -266,7 +266,8 @@ class ManiphestTransactionDetailView extends AphrontView { $old_raw = nonempty($old, array()); $new_raw = nonempty($new, array()); - foreach (array('DREV', 'FILE') as $type) { + foreach (array(PhabricatorPHIDConstants::PHID_TYPE_DREV, + PhabricatorPHIDConstants::PHID_TYPE_FILE) as $type) { $old = array_keys(idx($old_raw, $type, array())); $new = array_keys(idx($new_raw, $type, array())); if ($old != $new) { @@ -281,11 +282,11 @@ class ManiphestTransactionDetailView extends AphrontView { $rem_desc = $this->renderHandles($removed); switch ($type) { - case 'DREV': + case PhabricatorPHIDConstants::PHID_TYPE_DREV: $singular = 'Differential Revision'; $plural = 'Differential Revisions'; break; - case 'FILE': + case PhabricatorPHIDConstants::PHID_TYPE_FILE: $singular = 'file'; $plural = 'files'; break; diff --git a/src/applications/maniphest/view/transactiondetail/__init__.php b/src/applications/maniphest/view/transactiondetail/__init__.php index 9f08794372..a5700bb1af 100644 --- a/src/applications/maniphest/view/transactiondetail/__init__.php +++ b/src/applications/maniphest/view/transactiondetail/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/priority'); phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'view/base'); phutil_require_module('phabricator', 'view/utils'); diff --git a/src/applications/metamta/storage/mailinglist/PhabricatorMetaMTAMailingList.php b/src/applications/metamta/storage/mailinglist/PhabricatorMetaMTAMailingList.php index c8df2e35ab..49bbff7bfd 100644 --- a/src/applications/metamta/storage/mailinglist/PhabricatorMetaMTAMailingList.php +++ b/src/applications/metamta/storage/mailinglist/PhabricatorMetaMTAMailingList.php @@ -18,15 +18,14 @@ class PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO { - const TYPE_MAILING_LIST = 'MLST'; - protected $name; protected $phid; protected $email; protected $uri; public function generatePHID() { - return PhabricatorPHID::generateNewPHID(self::TYPE_MAILING_LIST); + return PhabricatorPHID::generateNewPHID( + PhabricatorPHIDConstants::PHID_TYPE_MLST); } public function getConfiguration() { diff --git a/src/applications/metamta/storage/mailinglist/__init__.php b/src/applications/metamta/storage/mailinglist/__init__.php index 6ca6793cb3..62022bbceb 100644 --- a/src/applications/metamta/storage/mailinglist/__init__.php +++ b/src/applications/metamta/storage/mailinglist/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'applications/metamta/storage/base'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); diff --git a/src/applications/people/storage/user/PhabricatorUser.php b/src/applications/people/storage/user/PhabricatorUser.php index f14d251952..bccb7d565d 100644 --- a/src/applications/people/storage/user/PhabricatorUser.php +++ b/src/applications/people/storage/user/PhabricatorUser.php @@ -18,8 +18,6 @@ class PhabricatorUser extends PhabricatorUserDAO { - const PHID_TYPE = 'USER'; - const SESSION_TABLE = 'phabricator_session'; protected $phid; @@ -49,7 +47,8 @@ class PhabricatorUser extends PhabricatorUserDAO { } public function generatePHID() { - return PhabricatorPHID::generateNewPHID(self::PHID_TYPE); + return PhabricatorPHID::generateNewPHID( + PhabricatorPHIDConstants::PHID_TYPE_USER); } public function setPassword($password) { diff --git a/src/applications/people/storage/user/__init__.php b/src/applications/people/storage/user/__init__.php index 3be82cddf2..efe13374b1 100644 --- a/src/applications/people/storage/user/__init__.php +++ b/src/applications/people/storage/user/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'applications/people/storage/base'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'storage/queryfx'); diff --git a/src/applications/phid/constants/PhabricatorPHIDConstants.php b/src/applications/phid/constants/PhabricatorPHIDConstants.php new file mode 100644 index 0000000000..e8363a9d71 --- /dev/null +++ b/src/applications/phid/constants/PhabricatorPHIDConstants.php @@ -0,0 +1,30 @@ +getType()) { - case 'USER': + case PhabricatorPHIDConstants::PHID_TYPE_USER: $name = $this->getName(); break; default: diff --git a/src/applications/phid/handle/__init__.php b/src/applications/phid/handle/__init__.php index 781f961e90..4d4b4ebbad 100644 --- a/src/applications/phid/handle/__init__.php +++ b/src/applications/phid/handle/__init__.php @@ -6,6 +6,8 @@ +phutil_require_module('phabricator', 'applications/phid/constants'); + phutil_require_module('phutil', 'markup'); diff --git a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php index 72433f3315..3445629d9d 100644 --- a/src/applications/phid/handle/data/PhabricatorObjectHandleData.php +++ b/src/applications/phid/handle/data/PhabricatorObjectHandleData.php @@ -18,8 +18,6 @@ class PhabricatorObjectHandleData { - const TYPE_UNKNOWN = '????'; - private $phids; public function __construct(array $phids) { @@ -38,7 +36,7 @@ class PhabricatorObjectHandleData { foreach ($types as $type => $phids) { switch ($type) { - case '!!!!': + case PhabricatorPHIDConstants::PHID_TYPE_MAGIC: // Black magic! foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); @@ -55,7 +53,7 @@ class PhabricatorObjectHandleData { $handles[$phid] = $handle; } break; - case 'USER': + case PhabricatorPHIDConstants::PHID_TYPE_USER: $class = 'PhabricatorUser'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); @@ -86,7 +84,7 @@ class PhabricatorObjectHandleData { $handles[$phid] = $handle; } break; - case 'MLST': + case PhabricatorPHIDConstants::PHID_TYPE_MLST: $class = 'PhabricatorMetaMTAMailingList'; PhutilSymbolLoader::loadClass($class); @@ -111,7 +109,7 @@ class PhabricatorObjectHandleData { $handles[$phid] = $handle; } break; - case 'DREV': + case PhabricatorPHIDConstants::PHID_TYPE_DREV: $class = 'DifferentialRevision'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); @@ -134,7 +132,7 @@ class PhabricatorObjectHandleData { $handles[$phid] = $handle; } break; - case 'TASK': + case PhabricatorPHIDConstants::PHID_TYPE_TASK: $class = 'ManiphestTask'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); @@ -157,7 +155,7 @@ class PhabricatorObjectHandleData { $handles[$phid] = $handle; } break; - case 'FILE': + case PhabricatorPHIDConstants::PHID_TYPE_FILE: $class = 'PhabricatorFile'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); @@ -179,7 +177,7 @@ class PhabricatorObjectHandleData { $handles[$phid] = $handle; } break; - case 'PROJ': + case PhabricatorPHIDConstants::PHID_TYPE_PROJ: $class = 'PhabricatorProject'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); @@ -222,7 +220,7 @@ class PhabricatorObjectHandleData { if (preg_match('/^PHID-([^-]{4})-/', $phid, $matches)) { return $matches[1]; } - return self::TYPE_UNKNOWN; + return PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN; } } diff --git a/src/applications/phid/handle/data/__init__.php b/src/applications/phid/handle/data/__init__.php index a80c17a0cb..b01d560e70 100644 --- a/src/applications/phid/handle/data/__init__.php +++ b/src/applications/phid/handle/data/__init__.php @@ -7,6 +7,7 @@ phutil_require_module('phabricator', 'applications/files/uri'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle'); phutil_require_module('phutil', 'symbols'); diff --git a/src/applications/project/storage/project/PhabricatorProject.php b/src/applications/project/storage/project/PhabricatorProject.php index 3263270acb..3064c20207 100644 --- a/src/applications/project/storage/project/PhabricatorProject.php +++ b/src/applications/project/storage/project/PhabricatorProject.php @@ -29,7 +29,8 @@ class PhabricatorProject extends PhabricatorProjectDAO { } public function generatePHID() { - return PhabricatorPHID::generateNewPHID('PROJ'); + return PhabricatorPHID::generateNewPHID( + PhabricatorPHIDConstants::PHID_TYPE_PROJ); } } diff --git a/src/applications/project/storage/project/__init__.php b/src/applications/project/storage/project/__init__.php index 89105fe95c..f378038d02 100644 --- a/src/applications/project/storage/project/__init__.php +++ b/src/applications/project/storage/project/__init__.php @@ -6,6 +6,7 @@ +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'applications/project/storage/base'); diff --git a/src/applications/search/controller/search/PhabricatorSearchController.php b/src/applications/search/controller/search/PhabricatorSearchController.php index 4898f01df4..f982706832 100644 --- a/src/applications/search/controller/search/PhabricatorSearchController.php +++ b/src/applications/search/controller/search/PhabricatorSearchController.php @@ -67,8 +67,8 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController { $options = array( '' => 'All Documents', - 'DREV' => 'Differential Revisions', - 'TASK' => 'Maniphest Tasks', + PhabricatorPHIDConstants::PHID_TYPE_DREV => 'Differential Revisions', + PhabricatorPHIDConstants::PHID_TYPE_TASK => 'Maniphest Tasks', ); $status_options = array( diff --git a/src/applications/search/controller/search/__init__.php b/src/applications/search/controller/search/__init__.php index a116849ddf..c91e268a6f 100644 --- a/src/applications/search/controller/search/__init__.php +++ b/src/applications/search/controller/search/__init__.php @@ -8,6 +8,7 @@ phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/redirect'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/search/controller/base'); phutil_require_module('phabricator', 'applications/search/execute/mysql'); diff --git a/src/applications/search/index/indexer/differential/PhabricatorSearchDifferentialIndexer.php b/src/applications/search/index/indexer/differential/PhabricatorSearchDifferentialIndexer.php index 8e0af71606..e22f7308cb 100644 --- a/src/applications/search/index/indexer/differential/PhabricatorSearchDifferentialIndexer.php +++ b/src/applications/search/index/indexer/differential/PhabricatorSearchDifferentialIndexer.php @@ -22,7 +22,7 @@ class PhabricatorSearchDifferentialIndexer public static function indexRevision(DifferentialRevision $rev) { $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($rev->getPHID()); - $doc->setDocumentType('DREV'); + $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_DREV); $doc->setDocumentTitle($rev->getTitle()); $doc->setDocumentCreated($rev->getDateCreated()); $doc->setDocumentModified($rev->getDateModified()); @@ -37,7 +37,7 @@ class PhabricatorSearchDifferentialIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $rev->getAuthorPHID(), - 'USER', + PhabricatorPHIDConstants::PHID_TYPE_USER, $rev->getDateCreated()); if ($rev->getStatus() != DifferentialRevisionStatus::COMMITTED && @@ -45,7 +45,7 @@ class PhabricatorSearchDifferentialIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $rev->getPHID(), - 'DREV', + PhabricatorPHIDConstants::PHID_TYPE_DREV, time()); } @@ -71,7 +71,7 @@ class PhabricatorSearchDifferentialIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, $touch, - 'USER', + PhabricatorPHIDConstants::PHID_TYPE_USER, $time); } @@ -81,7 +81,7 @@ class PhabricatorSearchDifferentialIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $phid, - 'USER', + PhabricatorPHIDConstants::PHID_TYPE_USER, $rev->getDateModified()); // Bogus timestamp. } diff --git a/src/applications/search/index/indexer/differential/__init__.php b/src/applications/search/index/indexer/differential/__init__.php index 9dda223db2..bb280993f1 100644 --- a/src/applications/search/index/indexer/differential/__init__.php +++ b/src/applications/search/index/indexer/differential/__init__.php @@ -8,6 +8,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/search/constants/field'); phutil_require_module('phabricator', 'applications/search/constants/relationship'); diff --git a/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php b/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php index b6e0af88e6..f4bf4cca02 100644 --- a/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php +++ b/src/applications/search/index/indexer/maniphest/PhabricatorSearchManiphestIndexer.php @@ -22,7 +22,7 @@ class PhabricatorSearchManiphestIndexer public static function indexTask(ManiphestTask $task) { $doc = new PhabricatorSearchAbstractDocument(); $doc->setPHID($task->getPHID()); - $doc->setDocumentType('TASK'); + $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_TASK); $doc->setDocumentTitle($task->getTitle()); $doc->setDocumentCreated($task->getDateCreated()); $doc->setDocumentModified($task->getDateModified()); @@ -34,14 +34,14 @@ class PhabricatorSearchManiphestIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $task->getAuthorPHID(), - 'USER', + PhabricatorPHIDConstants::PHID_TYPE_USER, $task->getDateCreated()); if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $task->getPHID(), - 'TASK', + PhabricatorPHIDConstants::PHID_TYPE_TASK, time()); } @@ -87,7 +87,7 @@ class PhabricatorSearchManiphestIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, $phid, - 'PROJ', + PhabricatorPHIDConstants::PHID_TYPE_PROJ, $task->getDateModified()); // Bogus. } @@ -95,13 +95,13 @@ class PhabricatorSearchManiphestIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $owner->getNewValue(), - 'USER', + PhabricatorPHIDConstants::PHID_TYPE_USER, $owner->getDateCreated()); } else { $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_OWNER, 'PHID-!!!!-UP-FOR-GRABS', - '!!!!', + PhabricatorPHIDConstants::PHID_TYPE_MAGIC, $owner ? $owner->getDateCreated() : $task->getDateCreated()); @@ -111,7 +111,7 @@ class PhabricatorSearchManiphestIndexer $doc->addRelationship( PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, $touch, - 'USER', + PhabricatorPHIDConstants::PHID_TYPE_USER, $time); } diff --git a/src/applications/search/index/indexer/maniphest/__init__.php b/src/applications/search/index/indexer/maniphest/__init__.php index 62fe069f4e..a6e5eecdb5 100644 --- a/src/applications/search/index/indexer/maniphest/__init__.php +++ b/src/applications/search/index/indexer/maniphest/__init__.php @@ -9,6 +9,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); +phutil_require_module('phabricator', 'applications/phid/constants'); phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'applications/search/constants/field'); phutil_require_module('phabricator', 'applications/search/constants/relationship');