1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Merge branch 'master' of github.com:facebook/phabricator

This commit is contained in:
epriestley 2011-03-03 15:48:46 -08:00
commit 90e10f4d0c
41 changed files with 130 additions and 85 deletions

View file

@ -14,6 +14,10 @@
"aphront" : "Aphront (Web Stack)", "aphront" : "Aphront (Web Stack)",
"console" : "DarkConsole (Debugging Console)", "console" : "DarkConsole (Debugging Console)",
"storage" : "Storage" "storage" : "Storage"
} },
"engines" : [
["DivinerArticleEngine", {}],
["DivinerXHPEngine", {}]
]
} }

View file

@ -226,6 +226,7 @@ phutil_register_library_map(array(
'PhabricatorObjectSelectorDialog' => 'view/control/objectselector', 'PhabricatorObjectSelectorDialog' => 'view/control/objectselector',
'PhabricatorPHID' => 'applications/phid/storage/phid', 'PhabricatorPHID' => 'applications/phid/storage/phid',
'PhabricatorPHIDAllocateController' => 'applications/phid/controller/allocate', 'PhabricatorPHIDAllocateController' => 'applications/phid/controller/allocate',
'PhabricatorPHIDConstants' => 'applications/phid/constants',
'PhabricatorPHIDController' => 'applications/phid/controller/base', 'PhabricatorPHIDController' => 'applications/phid/controller/base',
'PhabricatorPHIDDAO' => 'applications/phid/storage/base', 'PhabricatorPHIDDAO' => 'applications/phid/storage/base',
'PhabricatorPHIDListController' => 'applications/phid/controller/list', 'PhabricatorPHIDListController' => 'applications/phid/controller/list',

View file

@ -38,7 +38,8 @@ class DifferentialAttachController extends DifferentialController {
if ($request->isFormPost()) { if ($request->isFormPost()) {
$phids = explode(';', $request->getStr('phids')); $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)) { if (($phids || $old_phids) && ($phids != $old_phids)) {
$tasks = id(new ManiphestTask())->loadAllWhere( $tasks = id(new ManiphestTask())->loadAllWhere(
@ -59,22 +60,24 @@ class DifferentialAttachController extends DifferentialController {
$transaction->setAuthorPHID($user->getPHID()); $transaction->setAuthorPHID($user->getPHID());
$transaction->setTransactionType($type); $transaction->setTransactionType($type);
$new = $task->getAttached(); $new = $task->getAttached();
if (empty($new['DREV'])) { if (empty($new[PhabricatorPHIDConstants::PHID_TYPE_DREV])) {
$new['DREV'] = array(); $new[PhabricatorPHIDConstants::PHID_TYPE_DREV] = array();
} }
$rev_phid = $revision->getPHID(); $rev_phid = $revision->getPHID();
if (in_array($task->getPHID(), $phids)) { 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 // TODO: maybe the transaction editor should be responsible for
// this? // this?
continue; continue;
} }
$new['DREV'][$rev_phid] = array(); $new[PhabricatorPHIDConstants::PHID_TYPE_DREV][$rev_phid] = array();
} else { } else {
if (!in_array($rev_phid, $task->getAttachedPHIDs('DREV'))) { if (!in_array($rev_phid, $task->getAttachedPHIDs(
PhabricatorPHIDConstants::PHID_TYPE_DREV))) {
continue; continue;
} }
unset($new['DREV'][$rev_phid]); unset($new[PhabricatorPHIDConstants::PHID_TYPE_DREV][$rev_phid]);
} }
$transaction->setNewValue($new); $transaction->setNewValue($new);
$editor->applyTransactions($task, array($transaction)); $editor->applyTransactions($task, array($transaction));

View file

@ -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/editor/transaction');
phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/task');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); 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/phid/handle/data');
phutil_require_module('phabricator', 'view/control/objectselector'); phutil_require_module('phabricator', 'view/control/objectselector');

View file

@ -234,7 +234,8 @@ class DifferentialRevisionViewController extends DifferentialController {
$umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff); $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
$properties['Unit'] = $ustar.' '.$umsg; $properties['Unit'] = $ustar.' '.$umsg;
$tasks = $revision->getAttachedPHIDs('TASK'); $tasks = $revision->getAttachedPHIDs(
PhabricatorPHIDConstants::PHID_TYPE_TASK);
if ($tasks) { if ($tasks) {
$links = array(); $links = array();
foreach ($tasks as $task_phid) { foreach ($tasks as $task_phid) {

View file

@ -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/revisiondetail');
phutil_require_module('phabricator', 'applications/differential/view/revisionupdatehistory'); phutil_require_module('phabricator', 'applications/differential/view/revisionupdatehistory');
phutil_require_module('phabricator', 'applications/draft/storage/draft'); 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', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'view/form/error'); phutil_require_module('phabricator', 'view/form/error');

View file

@ -62,7 +62,8 @@ class DifferentialRevision extends DifferentialDAO {
} }
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID('DREV'); return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_DREV);
} }
public function loadDiffs() { public function loadDiffs() {

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'applications/differential/storage/base'); phutil_require_module('phabricator', 'applications/differential/storage/base');
phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/diff'); 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', 'applications/phid/storage/phid');
phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'storage/queryfx');

View file

@ -22,8 +22,6 @@ class PhabricatorFile extends PhabricatorFileDAO {
const STORAGE_FORMAT_RAW = 'raw'; const STORAGE_FORMAT_RAW = 'raw';
const PHID_TYPE = 'FILE';
// TODO: We need to reconcile this with MySQL packet size. // TODO: We need to reconcile this with MySQL packet size.
const FILE_SIZE_BYTE_LIMIT = 12582912; const FILE_SIZE_BYTE_LIMIT = 12582912;
@ -43,7 +41,8 @@ class PhabricatorFile extends PhabricatorFileDAO {
} }
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID(self::PHID_TYPE); return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_FILE);
} }
public static function newFromPHPUpload($spec, array $params = array()) { public static function newFromPHPUpload($spec, array $params = array()) {

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'applications/files/storage/base'); phutil_require_module('phabricator', 'applications/files/storage/base');
phutil_require_module('phabricator', 'applications/files/storage/storageblob'); phutil_require_module('phabricator', 'applications/files/storage/storageblob');
phutil_require_module('phabricator', 'applications/files/uri'); 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', 'applications/phid/storage/phid');
phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/env');

View file

@ -107,8 +107,8 @@ class ManiphestTaskDetailController extends ManiphestController {
$dict['Projects'] = '<em>None</em>'; $dict['Projects'] = '<em>None</em>';
} }
if (idx($attached, 'DREV')) { if (idx($attached, PhabricatorPHIDConstants::PHID_TYPE_DREV)) {
$revs = idx($attached, 'DREV'); $revs = idx($attached, PhabricatorPHIDConstants::PHID_TYPE_DREV);
$rev_links = array(); $rev_links = array();
foreach ($revs as $rev => $info) { foreach ($revs as $rev => $info) {
$rev_links[] = $handles[$rev]->renderLink(); $rev_links[] = $handles[$rev]->renderLink();
@ -117,8 +117,8 @@ class ManiphestTaskDetailController extends ManiphestController {
$dict['Revisions'] = $rev_links; $dict['Revisions'] = $rev_links;
} }
if (idx($attached, 'FILE')) { if (idx($attached, PhabricatorPHIDConstants::PHID_TYPE_FILE)) {
$revs = idx($attached, 'FILE'); $revs = idx($attached, PhabricatorPHIDConstants::PHID_TYPE_FILE);
$rev_links = array(); $rev_links = array();
foreach ($revs as $rev => $info) { foreach ($revs as $rev => $info) {
$rev_links[] = $handles[$rev]->renderLink(); $rev_links[] = $handles[$rev]->renderLink();

View file

@ -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/task');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist'); 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', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api');

View file

@ -24,7 +24,7 @@ class ManiphestTaskSelectorSearchController extends ManiphestController {
$query = new PhabricatorSearchQuery(); $query = new PhabricatorSearchQuery();
$query->setQuery($request->getStr('query')); $query->setQuery($request->getStr('query'));
$query->setParameter('type', 'TASK'); $query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_TASK);
switch ($request->getStr('filter')) { switch ($request->getStr('filter')) {
case 'assigned': case 'assigned':

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/maniphest/controller/base'); 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/data');
phutil_require_module('phabricator', 'applications/phid/handle/view/selector'); phutil_require_module('phabricator', 'applications/phid/handle/view/selector');
phutil_require_module('phabricator', 'applications/search/execute/mysql'); phutil_require_module('phabricator', 'applications/search/execute/mysql');

View file

@ -76,10 +76,10 @@ class ManiphestTransactionSaveController extends ManiphestController {
} }
if ($phid) { if ($phid) {
$new = $task->getAttached(); $new = $task->getAttached();
if (empty($new['FILE'])) { if (empty($new[PhabricatorPHIDConstants::PHID_TYPE_FILE])) {
$new['FILE'] = array(); $new[PhabricatorPHIDConstants::PHID_TYPE_FILE] = array();
} }
$new['FILE'][$phid] = array(); $new[PhabricatorPHIDConstants::PHID_TYPE_FILE][$phid] = array();
} }
$transaction->setNewValue($new); $transaction->setNewValue($new);

View file

@ -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/editor/transaction');
phutil_require_module('phabricator', 'applications/maniphest/storage/task'); phutil_require_module('phabricator', 'applications/maniphest/storage/task');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -48,7 +48,8 @@ class ManiphestTask extends ManiphestDAO {
} }
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID('TASK'); return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_TASK);
} }
public function getCCPHIDs() { public function getCCPHIDs() {

View file

@ -7,6 +7,7 @@
phutil_require_module('phabricator', 'applications/maniphest/storage/base'); 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('phabricator', 'applications/phid/storage/phid');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -266,7 +266,8 @@ class ManiphestTransactionDetailView extends AphrontView {
$old_raw = nonempty($old, array()); $old_raw = nonempty($old, array());
$new_raw = nonempty($new, 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())); $old = array_keys(idx($old_raw, $type, array()));
$new = array_keys(idx($new_raw, $type, array())); $new = array_keys(idx($new_raw, $type, array()));
if ($old != $new) { if ($old != $new) {
@ -281,11 +282,11 @@ class ManiphestTransactionDetailView extends AphrontView {
$rem_desc = $this->renderHandles($removed); $rem_desc = $this->renderHandles($removed);
switch ($type) { switch ($type) {
case 'DREV': case PhabricatorPHIDConstants::PHID_TYPE_DREV:
$singular = 'Differential Revision'; $singular = 'Differential Revision';
$plural = 'Differential Revisions'; $plural = 'Differential Revisions';
break; break;
case 'FILE': case PhabricatorPHIDConstants::PHID_TYPE_FILE:
$singular = 'file'; $singular = 'file';
$plural = 'files'; $plural = 'files';
break; break;

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'applications/maniphest/constants/priority'); phutil_require_module('phabricator', 'applications/maniphest/constants/priority');
phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/status');
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); 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', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'view/base'); phutil_require_module('phabricator', 'view/base');
phutil_require_module('phabricator', 'view/utils'); phutil_require_module('phabricator', 'view/utils');

View file

@ -18,15 +18,14 @@
class PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO { class PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO {
const TYPE_MAILING_LIST = 'MLST';
protected $name; protected $name;
protected $phid; protected $phid;
protected $email; protected $email;
protected $uri; protected $uri;
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID(self::TYPE_MAILING_LIST); return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_MLST);
} }
public function getConfiguration() { public function getConfiguration() {

View file

@ -7,6 +7,7 @@
phutil_require_module('phabricator', 'applications/metamta/storage/base'); phutil_require_module('phabricator', 'applications/metamta/storage/base');
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'applications/phid/storage/phid');

View file

@ -18,8 +18,6 @@
class PhabricatorUser extends PhabricatorUserDAO { class PhabricatorUser extends PhabricatorUserDAO {
const PHID_TYPE = 'USER';
const SESSION_TABLE = 'phabricator_session'; const SESSION_TABLE = 'phabricator_session';
protected $phid; protected $phid;
@ -49,7 +47,8 @@ class PhabricatorUser extends PhabricatorUserDAO {
} }
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID(self::PHID_TYPE); return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_USER);
} }
public function setPassword($password) { public function setPassword($password) {

View file

@ -7,6 +7,7 @@
phutil_require_module('phabricator', 'applications/people/storage/base'); 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', 'applications/phid/storage/phid');
phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'storage/queryfx');

View file

@ -0,0 +1,30 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorPHIDConstants {
const PHID_TYPE_USER = 'USER';
const PHID_TYPE_MLST = 'MLST';
const PHID_TYPE_DREV = 'DREV';
const PHID_TYPE_TASK = 'TASK';
const PHID_TYPE_FILE = 'FILE';
const PHID_TYPE_PROJ = 'PROJ';
const PHID_TYPE_UNKNOWN = '????';
const PHID_TYPE_MAGIC = '!!!!';
}

View file

@ -0,0 +1,10 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_source('PhabricatorPHIDConstants.php');

View file

@ -95,7 +95,7 @@ class PhabricatorObjectHandle {
public function renderLink() { public function renderLink() {
switch ($this->getType()) { switch ($this->getType()) {
case 'USER': case PhabricatorPHIDConstants::PHID_TYPE_USER:
$name = $this->getName(); $name = $this->getName();
break; break;
default: default:

View file

@ -6,6 +6,8 @@
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');

View file

@ -18,8 +18,6 @@
class PhabricatorObjectHandleData { class PhabricatorObjectHandleData {
const TYPE_UNKNOWN = '????';
private $phids; private $phids;
public function __construct(array $phids) { public function __construct(array $phids) {
@ -38,7 +36,7 @@ class PhabricatorObjectHandleData {
foreach ($types as $type => $phids) { foreach ($types as $type => $phids) {
switch ($type) { switch ($type) {
case '!!!!': case PhabricatorPHIDConstants::PHID_TYPE_MAGIC:
// Black magic! // Black magic!
foreach ($phids as $phid) { foreach ($phids as $phid) {
$handle = new PhabricatorObjectHandle(); $handle = new PhabricatorObjectHandle();
@ -55,7 +53,7 @@ class PhabricatorObjectHandleData {
$handles[$phid] = $handle; $handles[$phid] = $handle;
} }
break; break;
case 'USER': case PhabricatorPHIDConstants::PHID_TYPE_USER:
$class = 'PhabricatorUser'; $class = 'PhabricatorUser';
PhutilSymbolLoader::loadClass($class); PhutilSymbolLoader::loadClass($class);
$object = newv($class, array()); $object = newv($class, array());
@ -86,7 +84,7 @@ class PhabricatorObjectHandleData {
$handles[$phid] = $handle; $handles[$phid] = $handle;
} }
break; break;
case 'MLST': case PhabricatorPHIDConstants::PHID_TYPE_MLST:
$class = 'PhabricatorMetaMTAMailingList'; $class = 'PhabricatorMetaMTAMailingList';
PhutilSymbolLoader::loadClass($class); PhutilSymbolLoader::loadClass($class);
@ -111,7 +109,7 @@ class PhabricatorObjectHandleData {
$handles[$phid] = $handle; $handles[$phid] = $handle;
} }
break; break;
case 'DREV': case PhabricatorPHIDConstants::PHID_TYPE_DREV:
$class = 'DifferentialRevision'; $class = 'DifferentialRevision';
PhutilSymbolLoader::loadClass($class); PhutilSymbolLoader::loadClass($class);
$object = newv($class, array()); $object = newv($class, array());
@ -134,7 +132,7 @@ class PhabricatorObjectHandleData {
$handles[$phid] = $handle; $handles[$phid] = $handle;
} }
break; break;
case 'TASK': case PhabricatorPHIDConstants::PHID_TYPE_TASK:
$class = 'ManiphestTask'; $class = 'ManiphestTask';
PhutilSymbolLoader::loadClass($class); PhutilSymbolLoader::loadClass($class);
$object = newv($class, array()); $object = newv($class, array());
@ -157,7 +155,7 @@ class PhabricatorObjectHandleData {
$handles[$phid] = $handle; $handles[$phid] = $handle;
} }
break; break;
case 'FILE': case PhabricatorPHIDConstants::PHID_TYPE_FILE:
$class = 'PhabricatorFile'; $class = 'PhabricatorFile';
PhutilSymbolLoader::loadClass($class); PhutilSymbolLoader::loadClass($class);
$object = newv($class, array()); $object = newv($class, array());
@ -179,7 +177,7 @@ class PhabricatorObjectHandleData {
$handles[$phid] = $handle; $handles[$phid] = $handle;
} }
break; break;
case 'PROJ': case PhabricatorPHIDConstants::PHID_TYPE_PROJ:
$class = 'PhabricatorProject'; $class = 'PhabricatorProject';
PhutilSymbolLoader::loadClass($class); PhutilSymbolLoader::loadClass($class);
$object = newv($class, array()); $object = newv($class, array());
@ -222,7 +220,7 @@ class PhabricatorObjectHandleData {
if (preg_match('/^PHID-([^-]{4})-/', $phid, $matches)) { if (preg_match('/^PHID-([^-]{4})-/', $phid, $matches)) {
return $matches[1]; return $matches[1];
} }
return self::TYPE_UNKNOWN; return PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN;
} }
} }

View file

@ -7,6 +7,7 @@
phutil_require_module('phabricator', 'applications/files/uri'); phutil_require_module('phabricator', 'applications/files/uri');
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/handle'); phutil_require_module('phabricator', 'applications/phid/handle');
phutil_require_module('phutil', 'symbols'); phutil_require_module('phutil', 'symbols');

View file

@ -29,7 +29,8 @@ class PhabricatorProject extends PhabricatorProjectDAO {
} }
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID('PROJ'); return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_PROJ);
} }
} }

View file

@ -6,6 +6,7 @@
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/storage/phid'); phutil_require_module('phabricator', 'applications/phid/storage/phid');
phutil_require_module('phabricator', 'applications/project/storage/base'); phutil_require_module('phabricator', 'applications/project/storage/base');

View file

@ -67,8 +67,8 @@ class PhabricatorSearchController extends PhabricatorSearchBaseController {
$options = array( $options = array(
'' => 'All Documents', '' => 'All Documents',
'DREV' => 'Differential Revisions', PhabricatorPHIDConstants::PHID_TYPE_DREV => 'Differential Revisions',
'TASK' => 'Maniphest Tasks', PhabricatorPHIDConstants::PHID_TYPE_TASK => 'Maniphest Tasks',
); );
$status_options = array( $status_options = array(

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'aphront/response/404'); phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect'); 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/phid/handle/data');
phutil_require_module('phabricator', 'applications/search/controller/base'); phutil_require_module('phabricator', 'applications/search/controller/base');
phutil_require_module('phabricator', 'applications/search/execute/mysql'); phutil_require_module('phabricator', 'applications/search/execute/mysql');

View file

@ -22,7 +22,7 @@ class PhabricatorSearchDifferentialIndexer
public static function indexRevision(DifferentialRevision $rev) { public static function indexRevision(DifferentialRevision $rev) {
$doc = new PhabricatorSearchAbstractDocument(); $doc = new PhabricatorSearchAbstractDocument();
$doc->setPHID($rev->getPHID()); $doc->setPHID($rev->getPHID());
$doc->setDocumentType('DREV'); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_DREV);
$doc->setDocumentTitle($rev->getTitle()); $doc->setDocumentTitle($rev->getTitle());
$doc->setDocumentCreated($rev->getDateCreated()); $doc->setDocumentCreated($rev->getDateCreated());
$doc->setDocumentModified($rev->getDateModified()); $doc->setDocumentModified($rev->getDateModified());
@ -37,7 +37,7 @@ class PhabricatorSearchDifferentialIndexer
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
$rev->getAuthorPHID(), $rev->getAuthorPHID(),
'USER', PhabricatorPHIDConstants::PHID_TYPE_USER,
$rev->getDateCreated()); $rev->getDateCreated());
if ($rev->getStatus() != DifferentialRevisionStatus::COMMITTED && if ($rev->getStatus() != DifferentialRevisionStatus::COMMITTED &&
@ -45,7 +45,7 @@ class PhabricatorSearchDifferentialIndexer
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OPEN, PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
$rev->getPHID(), $rev->getPHID(),
'DREV', PhabricatorPHIDConstants::PHID_TYPE_DREV,
time()); time());
} }
@ -71,7 +71,7 @@ class PhabricatorSearchDifferentialIndexer
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, PhabricatorSearchRelationship::RELATIONSHIP_TOUCH,
$touch, $touch,
'USER', PhabricatorPHIDConstants::PHID_TYPE_USER,
$time); $time);
} }
@ -81,7 +81,7 @@ class PhabricatorSearchDifferentialIndexer
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
$phid, $phid,
'USER', PhabricatorPHIDConstants::PHID_TYPE_USER,
$rev->getDateModified()); // Bogus timestamp. $rev->getDateModified()); // Bogus timestamp.
} }

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
phutil_require_module('phabricator', 'applications/differential/storage/inlinecomment'); 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/phid/handle/data');
phutil_require_module('phabricator', 'applications/search/constants/field'); phutil_require_module('phabricator', 'applications/search/constants/field');
phutil_require_module('phabricator', 'applications/search/constants/relationship'); phutil_require_module('phabricator', 'applications/search/constants/relationship');

View file

@ -22,7 +22,7 @@ class PhabricatorSearchManiphestIndexer
public static function indexTask(ManiphestTask $task) { public static function indexTask(ManiphestTask $task) {
$doc = new PhabricatorSearchAbstractDocument(); $doc = new PhabricatorSearchAbstractDocument();
$doc->setPHID($task->getPHID()); $doc->setPHID($task->getPHID());
$doc->setDocumentType('TASK'); $doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_TASK);
$doc->setDocumentTitle($task->getTitle()); $doc->setDocumentTitle($task->getTitle());
$doc->setDocumentCreated($task->getDateCreated()); $doc->setDocumentCreated($task->getDateCreated());
$doc->setDocumentModified($task->getDateModified()); $doc->setDocumentModified($task->getDateModified());
@ -34,14 +34,14 @@ class PhabricatorSearchManiphestIndexer
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
$task->getAuthorPHID(), $task->getAuthorPHID(),
'USER', PhabricatorPHIDConstants::PHID_TYPE_USER,
$task->getDateCreated()); $task->getDateCreated());
if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) { if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OPEN, PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
$task->getPHID(), $task->getPHID(),
'TASK', PhabricatorPHIDConstants::PHID_TYPE_TASK,
time()); time());
} }
@ -87,7 +87,7 @@ class PhabricatorSearchManiphestIndexer
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, PhabricatorSearchRelationship::RELATIONSHIP_PROJECT,
$phid, $phid,
'PROJ', PhabricatorPHIDConstants::PHID_TYPE_PROJ,
$task->getDateModified()); // Bogus. $task->getDateModified()); // Bogus.
} }
@ -95,13 +95,13 @@ class PhabricatorSearchManiphestIndexer
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
$owner->getNewValue(), $owner->getNewValue(),
'USER', PhabricatorPHIDConstants::PHID_TYPE_USER,
$owner->getDateCreated()); $owner->getDateCreated());
} else { } else {
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_OWNER, PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
'PHID-!!!!-UP-FOR-GRABS', 'PHID-!!!!-UP-FOR-GRABS',
'!!!!', PhabricatorPHIDConstants::PHID_TYPE_MAGIC,
$owner $owner
? $owner->getDateCreated() ? $owner->getDateCreated()
: $task->getDateCreated()); : $task->getDateCreated());
@ -111,7 +111,7 @@ class PhabricatorSearchManiphestIndexer
$doc->addRelationship( $doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_TOUCH, PhabricatorSearchRelationship::RELATIONSHIP_TOUCH,
$touch, $touch,
'USER', PhabricatorPHIDConstants::PHID_TYPE_USER,
$time); $time);
} }

View file

@ -9,6 +9,7 @@
phutil_require_module('phabricator', 'applications/maniphest/constants/status'); phutil_require_module('phabricator', 'applications/maniphest/constants/status');
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype'); phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction'); 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/phid/handle/data');
phutil_require_module('phabricator', 'applications/search/constants/field'); phutil_require_module('phabricator', 'applications/search/constants/field');
phutil_require_module('phabricator', 'applications/search/constants/relationship'); phutil_require_module('phabricator', 'applications/search/constants/relationship');

View file

@ -36,21 +36,15 @@ abstract class AphrontDatabaseConnection {
abstract public function escapeStringForLikeClause($string); abstract public function escapeStringForLikeClause($string);
public function queryData($pattern/*, $arg, $arg, ... */) { 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(); $args = func_get_args();
array_unshift($args, $this); 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, ... */) { public function query($pattern/*, $arg, $arg, ... */) {
$args = func_get_args(); $args = func_get_args();
array_unshift($args, $this); 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 // TODO: Probably need to reset these when we catch a connection exception

View file

@ -20,14 +20,8 @@
* @group storage * @group storage
*/ */
function queryfx(AphrontDatabaseConnection $conn, $sql/*, ... */) { 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(); $argv = func_get_args();
$query = hphp_workaround_call_user_func_array('qsprintf', $argv); $query = call_user_func_array('qsprintf', $argv);
$conn->executeRawQuery($query); $conn->executeRawQuery($query);
} }
@ -36,7 +30,7 @@ function queryfx(AphrontDatabaseConnection $conn, $sql/*, ... */) {
*/ */
function vqueryfx($conn, $sql, $argv) { function vqueryfx($conn, $sql, $argv) {
array_unshift($argv, $conn, $sql); 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/*, ... */) { function queryfx_all($conn, $sql/*, ... */) {
$argv = func_get_args(); $argv = func_get_args();
hphp_workaround_call_user_func_array('queryfx', $argv); call_user_func_array('queryfx', $argv);
return $conn->selectAllResults(); return $conn->selectAllResults();
} }
@ -53,7 +47,7 @@ function queryfx_all($conn, $sql/*, ... */) {
*/ */
function queryfx_one($conn, $sql/*, ... */) { function queryfx_one($conn, $sql/*, ... */) {
$argv = func_get_args(); $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) { if (count($ret) > 1) {
throw new AphrontQueryCountException( throw new AphrontQueryCountException(
'Query returned more than one row.'); 'Query returned more than one row.');
@ -65,6 +59,6 @@ function queryfx_one($conn, $sql/*, ... */) {
function vqueryfx_all($conn, $sql, array $argv) { function vqueryfx_all($conn, $sql, array $argv) {
array_unshift($argv, $conn, $sql); array_unshift($argv, $conn, $sql);
hphp_workaround_call_user_func_array('queryfx', $argv); call_user_func_array('queryfx', $argv);
return $conn->selectAllResults(); return $conn->selectAllResults();
} }

View file

@ -176,12 +176,3 @@ function phabricator_fatal_config_error($msg) {
die(); 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);
}