mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
Merge branch 'master' into redesign-2015
This commit is contained in:
commit
4b298c1c44
10 changed files with 110 additions and 43 deletions
|
@ -11,8 +11,15 @@ final class PhabricatorPlatformSite extends PhabricatorSite {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newSiteForRequest(AphrontRequest $request) {
|
public function newSiteForRequest(AphrontRequest $request) {
|
||||||
|
// If no base URI has been configured yet, match this site so the user
|
||||||
|
// can follow setup instructions.
|
||||||
|
$base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
|
||||||
|
if (!strlen($base_uri)) {
|
||||||
|
return new PhabricatorPlatformSite();
|
||||||
|
}
|
||||||
|
|
||||||
$uris = array();
|
$uris = array();
|
||||||
$uris[] = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
|
$uris[] = $base_uri;
|
||||||
$uris[] = PhabricatorEnv::getEnvConfig('phabricator.production-uri');
|
$uris[] = PhabricatorEnv::getEnvConfig('phabricator.production-uri');
|
||||||
|
|
||||||
$allowed = PhabricatorEnv::getEnvConfig('phabricator.allowed-uris');
|
$allowed = PhabricatorEnv::getEnvConfig('phabricator.allowed-uris');
|
||||||
|
|
|
@ -78,10 +78,11 @@ abstract class PhabricatorFeedStory
|
||||||
$object_phids += $phids;
|
$object_phids += $phids;
|
||||||
}
|
}
|
||||||
|
|
||||||
$objects = id(new PhabricatorObjectQuery())
|
$object_query = id(new PhabricatorObjectQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withPHIDs(array_keys($object_phids))
|
->withPHIDs(array_keys($object_phids));
|
||||||
->execute();
|
|
||||||
|
$objects = $object_query->execute();
|
||||||
|
|
||||||
foreach ($key_phids as $key => $phids) {
|
foreach ($key_phids as $key => $phids) {
|
||||||
if (!$phids) {
|
if (!$phids) {
|
||||||
|
@ -142,8 +143,13 @@ abstract class PhabricatorFeedStory
|
||||||
$handle_phids += $key_phids[$key];
|
$handle_phids += $key_phids[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: This setParentQuery() is a little sketchy. Ideally, this whole
|
||||||
|
// method should be inside FeedQuery and it should be the parent query of
|
||||||
|
// both subqueries. We're just trying to share the workspace cache.
|
||||||
|
|
||||||
$handles = id(new PhabricatorHandleQuery())
|
$handles = id(new PhabricatorHandleQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
->setParentQuery($object_query)
|
||||||
->withPHIDs(array_keys($handle_phids))
|
->withPHIDs(array_keys($handle_phids))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
@ -514,7 +520,7 @@ abstract class PhabricatorFeedStory
|
||||||
}
|
}
|
||||||
|
|
||||||
public function newMarkupEngine($field) {
|
public function newMarkupEngine($field) {
|
||||||
return PhabricatorMarkupEngine::newMarkupEngine(array());
|
return PhabricatorMarkupEngine::getEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMarkupText($field) {
|
public function getMarkupText($field) {
|
||||||
|
|
|
@ -1073,6 +1073,29 @@ final class PhabricatorUser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a scalar string identifying this user.
|
||||||
|
*
|
||||||
|
* This is similar to using the PHID, but distinguishes between ominpotent
|
||||||
|
* and public users explicitly. This allows safe construction of cache keys
|
||||||
|
* or cache buckets which do not conflate public and omnipotent users.
|
||||||
|
*
|
||||||
|
* @return string Scalar identifier.
|
||||||
|
*/
|
||||||
|
public function getCacheFragment() {
|
||||||
|
if ($this->isOmnipotent()) {
|
||||||
|
return 'u.omnipotent';
|
||||||
|
}
|
||||||
|
|
||||||
|
$phid = $this->getPHID();
|
||||||
|
if ($phid) {
|
||||||
|
return 'u.'.$phid;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'u.public';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Managing Handles )--------------------------------------------------- */
|
/* -( Managing Handles )--------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ final class PhabricatorHandleQuery
|
||||||
|
|
||||||
$object_query = id(new PhabricatorObjectQuery())
|
$object_query = id(new PhabricatorObjectQuery())
|
||||||
->withPHIDs($phids)
|
->withPHIDs($phids)
|
||||||
|
->setParentQuery($this)
|
||||||
->requireCapabilities($this->getRequiredObjectCapabilities())
|
->requireCapabilities($this->getRequiredObjectCapabilities())
|
||||||
->setViewer($this->getViewer());
|
->setViewer($this->getViewer());
|
||||||
|
|
||||||
|
|
|
@ -106,19 +106,6 @@ final class PhabricatorObjectQuery
|
||||||
private function loadObjectsByPHID(array $types, array $phids) {
|
private function loadObjectsByPHID(array $types, array $phids) {
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$workspace = $this->getObjectsFromWorkspace($phids);
|
|
||||||
|
|
||||||
foreach ($phids as $key => $phid) {
|
|
||||||
if (isset($workspace[$phid])) {
|
|
||||||
$results[$phid] = $workspace[$phid];
|
|
||||||
unset($phids[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$phids) {
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
$groups = array();
|
$groups = array();
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$type = phid_get_type($phid);
|
$type = phid_get_type($phid);
|
||||||
|
@ -127,6 +114,21 @@ final class PhabricatorObjectQuery
|
||||||
|
|
||||||
$in_flight = $this->getPHIDsInFlight();
|
$in_flight = $this->getPHIDsInFlight();
|
||||||
foreach ($groups as $type => $group) {
|
foreach ($groups as $type => $group) {
|
||||||
|
// We check the workspace for each group, because some groups may trigger
|
||||||
|
// other groups to load (for example, transactions load their objects).
|
||||||
|
$workspace = $this->getObjectsFromWorkspace($group);
|
||||||
|
|
||||||
|
foreach ($group as $key => $phid) {
|
||||||
|
if (isset($workspace[$phid])) {
|
||||||
|
$results[$phid] = $workspace[$phid];
|
||||||
|
unset($group[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$group) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Don't try to load PHIDs which are already "in flight"; this prevents
|
// Don't try to load PHIDs which are already "in flight"; this prevents
|
||||||
// us from recursing indefinitely if policy checks or edges form a loop.
|
// us from recursing indefinitely if policy checks or edges form a loop.
|
||||||
// We will decline to load the corresponding objects.
|
// We will decline to load the corresponding objects.
|
||||||
|
@ -139,7 +141,10 @@ final class PhabricatorObjectQuery
|
||||||
if ($group && isset($types[$type])) {
|
if ($group && isset($types[$type])) {
|
||||||
$this->putPHIDsInFlight($group);
|
$this->putPHIDsInFlight($group);
|
||||||
$objects = $types[$type]->loadObjects($this, $group);
|
$objects = $types[$type]->loadObjects($this, $group);
|
||||||
$results += mpull($objects, null, 'getPHID');
|
|
||||||
|
$map = mpull($objects, null, 'getPHID');
|
||||||
|
$this->putObjectsInWorkspace($map);
|
||||||
|
$results += $map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,12 +196,18 @@ final class PhabricatorProjectQuery
|
||||||
$default = null;
|
$default = null;
|
||||||
|
|
||||||
$file_phids = mpull($projects, 'getProfileImagePHID');
|
$file_phids = mpull($projects, 'getProfileImagePHID');
|
||||||
$files = id(new PhabricatorFileQuery())
|
$file_phids = array_filter($file_phids);
|
||||||
->setParentQuery($this)
|
if ($file_phids) {
|
||||||
->setViewer($this->getViewer())
|
$files = id(new PhabricatorFileQuery())
|
||||||
->withPHIDs($file_phids)
|
->setParentQuery($this)
|
||||||
->execute();
|
->setViewer($this->getViewer())
|
||||||
$files = mpull($files, null, 'getPHID');
|
->withPHIDs($file_phids)
|
||||||
|
->execute();
|
||||||
|
$files = mpull($files, null, 'getPHID');
|
||||||
|
} else {
|
||||||
|
$files = array();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($projects as $project) {
|
foreach ($projects as $project) {
|
||||||
$file = idx($files, $project->getProfileImagePHID());
|
$file = idx($files, $project->getProfileImagePHID());
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
|
|
|
@ -143,7 +143,7 @@ final class PhabricatorSpacesNamespaceQuery
|
||||||
|
|
||||||
public static function getViewerSpaces(PhabricatorUser $viewer) {
|
public static function getViewerSpaces(PhabricatorUser $viewer) {
|
||||||
$cache = PhabricatorCaches::getRequestCache();
|
$cache = PhabricatorCaches::getRequestCache();
|
||||||
$cache_key = self::KEY_VIEWER.'('.$viewer->getPHID().')';
|
$cache_key = self::KEY_VIEWER.'('.$viewer->getCacheFragment().')';
|
||||||
|
|
||||||
$result = $cache->getKey($cache_key);
|
$result = $cache->getKey($cache_key);
|
||||||
if ($result === null) {
|
if ($result === null) {
|
||||||
|
|
|
@ -95,6 +95,7 @@ final class PhabricatorSubscriptionsEditController
|
||||||
$editor = id($object->getApplicationTransactionEditor())
|
$editor = id($object->getApplicationTransactionEditor())
|
||||||
->setActor($user)
|
->setActor($user)
|
||||||
->setContinueOnNoEffect(true)
|
->setContinueOnNoEffect(true)
|
||||||
|
->setContinueOnMissingFields(true)
|
||||||
->setContentSourceFromRequest($request);
|
->setContentSourceFromRequest($request);
|
||||||
|
|
||||||
$editor->applyTransactions(
|
$editor->applyTransactions(
|
||||||
|
|
|
@ -56,6 +56,17 @@ final class PhabricatorStandardCustomFieldRemarkup
|
||||||
$this->getFieldName());
|
$this->getFieldName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getApplicationTransactionTitleForFeed(
|
||||||
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
$author_phid = $xaction->getAuthorPHID();
|
||||||
|
$object_phid = $xaction->getObjectPHID();
|
||||||
|
return pht(
|
||||||
|
'%s edited %s on %s.',
|
||||||
|
$xaction->renderHandleLink($author_phid),
|
||||||
|
$this->getFieldName(),
|
||||||
|
$xaction->renderHandleLink($object_phid));
|
||||||
|
}
|
||||||
|
|
||||||
public function getApplicationTransactionHasChangeDetails(
|
public function getApplicationTransactionHasChangeDetails(
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -406,8 +406,8 @@ abstract class PhabricatorPolicyAwareQuery extends PhabricatorOffsetPagedQuery {
|
||||||
*
|
*
|
||||||
* **Fully enrich objects pulled from the workspace.** After pulling objects
|
* **Fully enrich objects pulled from the workspace.** After pulling objects
|
||||||
* from the workspace, you still need to load and attach any additional
|
* from the workspace, you still need to load and attach any additional
|
||||||
* content the query requests. Otherwise, a query might return objects without
|
* content the query requests. Otherwise, a query might return objects
|
||||||
* requested content.
|
* without requested content.
|
||||||
*
|
*
|
||||||
* Generally, you do not need to update the workspace yourself: it is
|
* Generally, you do not need to update the workspace yourself: it is
|
||||||
* automatically populated as a side effect of objects surviving policy
|
* automatically populated as a side effect of objects surviving policy
|
||||||
|
@ -419,16 +419,22 @@ abstract class PhabricatorPolicyAwareQuery extends PhabricatorOffsetPagedQuery {
|
||||||
* @task workspace
|
* @task workspace
|
||||||
*/
|
*/
|
||||||
public function putObjectsInWorkspace(array $objects) {
|
public function putObjectsInWorkspace(array $objects) {
|
||||||
assert_instances_of($objects, 'PhabricatorPolicyInterface');
|
$parent = $this->getParentQuery();
|
||||||
|
if ($parent) {
|
||||||
$viewer_phid = $this->getViewer()->getPHID();
|
$parent->putObjectsInWorkspace($objects);
|
||||||
|
return $this;
|
||||||
// The workspace is scoped per viewer to prevent accidental contamination.
|
|
||||||
if (empty($this->workspace[$viewer_phid])) {
|
|
||||||
$this->workspace[$viewer_phid] = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->workspace[$viewer_phid] += $objects;
|
assert_instances_of($objects, 'PhabricatorPolicyInterface');
|
||||||
|
|
||||||
|
$viewer_fragment = $this->getViewer()->getCacheFragment();
|
||||||
|
|
||||||
|
// The workspace is scoped per viewer to prevent accidental contamination.
|
||||||
|
if (empty($this->workspace[$viewer_fragment])) {
|
||||||
|
$this->workspace[$viewer_fragment] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->workspace[$viewer_fragment] += $objects;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -445,20 +451,21 @@ abstract class PhabricatorPolicyAwareQuery extends PhabricatorOffsetPagedQuery {
|
||||||
* @task workspace
|
* @task workspace
|
||||||
*/
|
*/
|
||||||
public function getObjectsFromWorkspace(array $phids) {
|
public function getObjectsFromWorkspace(array $phids) {
|
||||||
$viewer_phid = $this->getViewer()->getPHID();
|
$parent = $this->getParentQuery();
|
||||||
|
if ($parent) {
|
||||||
|
return $parent->getObjectsFromWorkspace($phids);
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewer_fragment = $this->getViewer()->getCacheFragment();
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($phids as $key => $phid) {
|
foreach ($phids as $key => $phid) {
|
||||||
if (isset($this->workspace[$viewer_phid][$phid])) {
|
if (isset($this->workspace[$viewer_fragment][$phid])) {
|
||||||
$results[$phid] = $this->workspace[$viewer_phid][$phid];
|
$results[$phid] = $this->workspace[$viewer_fragment][$phid];
|
||||||
unset($phids[$key]);
|
unset($phids[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($phids && $this->getParentQuery()) {
|
|
||||||
$results += $this->getParentQuery()->getObjectsFromWorkspace($phids);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue