mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-29 17:00:59 +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) {
|
||||
// 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[] = PhabricatorEnv::getEnvConfig('phabricator.base-uri');
|
||||
$uris[] = $base_uri;
|
||||
$uris[] = PhabricatorEnv::getEnvConfig('phabricator.production-uri');
|
||||
|
||||
$allowed = PhabricatorEnv::getEnvConfig('phabricator.allowed-uris');
|
||||
|
|
|
@ -78,10 +78,11 @@ abstract class PhabricatorFeedStory
|
|||
$object_phids += $phids;
|
||||
}
|
||||
|
||||
$objects = id(new PhabricatorObjectQuery())
|
||||
$object_query = id(new PhabricatorObjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withPHIDs(array_keys($object_phids))
|
||||
->execute();
|
||||
->withPHIDs(array_keys($object_phids));
|
||||
|
||||
$objects = $object_query->execute();
|
||||
|
||||
foreach ($key_phids as $key => $phids) {
|
||||
if (!$phids) {
|
||||
|
@ -142,8 +143,13 @@ abstract class PhabricatorFeedStory
|
|||
$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())
|
||||
->setViewer($viewer)
|
||||
->setParentQuery($object_query)
|
||||
->withPHIDs(array_keys($handle_phids))
|
||||
->execute();
|
||||
|
||||
|
@ -514,7 +520,7 @@ abstract class PhabricatorFeedStory
|
|||
}
|
||||
|
||||
public function newMarkupEngine($field) {
|
||||
return PhabricatorMarkupEngine::newMarkupEngine(array());
|
||||
return PhabricatorMarkupEngine::getEngine();
|
||||
}
|
||||
|
||||
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 )--------------------------------------------------- */
|
||||
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ final class PhabricatorHandleQuery
|
|||
|
||||
$object_query = id(new PhabricatorObjectQuery())
|
||||
->withPHIDs($phids)
|
||||
->setParentQuery($this)
|
||||
->requireCapabilities($this->getRequiredObjectCapabilities())
|
||||
->setViewer($this->getViewer());
|
||||
|
||||
|
|
|
@ -106,19 +106,6 @@ final class PhabricatorObjectQuery
|
|||
private function loadObjectsByPHID(array $types, array $phids) {
|
||||
$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();
|
||||
foreach ($phids as $phid) {
|
||||
$type = phid_get_type($phid);
|
||||
|
@ -127,6 +114,21 @@ final class PhabricatorObjectQuery
|
|||
|
||||
$in_flight = $this->getPHIDsInFlight();
|
||||
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
|
||||
// us from recursing indefinitely if policy checks or edges form a loop.
|
||||
// We will decline to load the corresponding objects.
|
||||
|
@ -139,7 +141,10 @@ final class PhabricatorObjectQuery
|
|||
if ($group && isset($types[$type])) {
|
||||
$this->putPHIDsInFlight($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;
|
||||
|
||||
$file_phids = mpull($projects, 'getProfileImagePHID');
|
||||
$file_phids = array_filter($file_phids);
|
||||
if ($file_phids) {
|
||||
$files = id(new PhabricatorFileQuery())
|
||||
->setParentQuery($this)
|
||||
->setViewer($this->getViewer())
|
||||
->withPHIDs($file_phids)
|
||||
->execute();
|
||||
$files = mpull($files, null, 'getPHID');
|
||||
} else {
|
||||
$files = array();
|
||||
}
|
||||
|
||||
foreach ($projects as $project) {
|
||||
$file = idx($files, $project->getProfileImagePHID());
|
||||
if (!$file) {
|
||||
|
|
|
@ -143,7 +143,7 @@ final class PhabricatorSpacesNamespaceQuery
|
|||
|
||||
public static function getViewerSpaces(PhabricatorUser $viewer) {
|
||||
$cache = PhabricatorCaches::getRequestCache();
|
||||
$cache_key = self::KEY_VIEWER.'('.$viewer->getPHID().')';
|
||||
$cache_key = self::KEY_VIEWER.'('.$viewer->getCacheFragment().')';
|
||||
|
||||
$result = $cache->getKey($cache_key);
|
||||
if ($result === null) {
|
||||
|
|
|
@ -95,6 +95,7 @@ final class PhabricatorSubscriptionsEditController
|
|||
$editor = id($object->getApplicationTransactionEditor())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContinueOnMissingFields(true)
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$editor->applyTransactions(
|
||||
|
|
|
@ -56,6 +56,17 @@ final class PhabricatorStandardCustomFieldRemarkup
|
|||
$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(
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
return true;
|
||||
|
|
|
@ -406,8 +406,8 @@ abstract class PhabricatorPolicyAwareQuery extends PhabricatorOffsetPagedQuery {
|
|||
*
|
||||
* **Fully enrich objects pulled from the workspace.** After pulling objects
|
||||
* from the workspace, you still need to load and attach any additional
|
||||
* content the query requests. Otherwise, a query might return objects without
|
||||
* requested content.
|
||||
* content the query requests. Otherwise, a query might return objects
|
||||
* without requested content.
|
||||
*
|
||||
* Generally, you do not need to update the workspace yourself: it is
|
||||
* automatically populated as a side effect of objects surviving policy
|
||||
|
@ -419,16 +419,22 @@ abstract class PhabricatorPolicyAwareQuery extends PhabricatorOffsetPagedQuery {
|
|||
* @task workspace
|
||||
*/
|
||||
public function putObjectsInWorkspace(array $objects) {
|
||||
assert_instances_of($objects, 'PhabricatorPolicyInterface');
|
||||
|
||||
$viewer_phid = $this->getViewer()->getPHID();
|
||||
|
||||
// The workspace is scoped per viewer to prevent accidental contamination.
|
||||
if (empty($this->workspace[$viewer_phid])) {
|
||||
$this->workspace[$viewer_phid] = array();
|
||||
$parent = $this->getParentQuery();
|
||||
if ($parent) {
|
||||
$parent->putObjectsInWorkspace($objects);
|
||||
return $this;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
@ -445,20 +451,21 @@ abstract class PhabricatorPolicyAwareQuery extends PhabricatorOffsetPagedQuery {
|
|||
* @task workspace
|
||||
*/
|
||||
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();
|
||||
foreach ($phids as $key => $phid) {
|
||||
if (isset($this->workspace[$viewer_phid][$phid])) {
|
||||
$results[$phid] = $this->workspace[$viewer_phid][$phid];
|
||||
if (isset($this->workspace[$viewer_fragment][$phid])) {
|
||||
$results[$phid] = $this->workspace[$viewer_fragment][$phid];
|
||||
unset($phids[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($phids && $this->getParentQuery()) {
|
||||
$results += $this->getParentQuery()->getObjectsFromWorkspace($phids);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue