Page MenuHomePhabricator

D13324.diff
No OneTemporary

D13324.diff

diff --git a/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php b/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php
--- a/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php
+++ b/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php
@@ -5,6 +5,7 @@
const KEY_ALL = 'spaces.all';
const KEY_DEFAULT = 'spaces.default';
+ const KEY_VIEWER = 'spaces.viewer';
private $ids;
private $phids;
@@ -141,17 +142,25 @@
}
public static function getViewerSpaces(PhabricatorUser $viewer) {
- $spaces = self::getAllSpaces();
+ $cache = PhabricatorCaches::getRequestCache();
+ $cache_key = self::KEY_VIEWER.'('.$viewer->getPHID().')';
- $result = array();
- foreach ($spaces as $key => $space) {
- $can_see = PhabricatorPolicyFilter::hasCapability(
- $viewer,
- $space,
- PhabricatorPolicyCapability::CAN_VIEW);
- if ($can_see) {
- $result[$key] = $space;
+ $result = $cache->getKey($cache_key);
+ if ($result === null) {
+ $spaces = self::getAllSpaces();
+
+ $result = array();
+ foreach ($spaces as $key => $space) {
+ $can_see = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $space,
+ PhabricatorPolicyCapability::CAN_VIEW);
+ if ($can_see) {
+ $result[$key] = $space;
+ }
}
+
+ $cache->setKey($cache_key, $result);
}
return $result;

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 31, 1:22 PM (16 h, 2 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7078623
Default Alt Text
D13324.diff (1 KB)

Event Timeline