From b10d128c598ca0bd9577491cd14e043b49bb4144 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Wed, 17 Jun 2015 20:41:52 +1000 Subject: [PATCH 1/4] Remove some unused properties Summary: These class properties don't seem to be used. Test Plan: Eyeball it. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13295 --- src/applications/celerity/resources/CelerityResources.php | 2 -- src/applications/phid/storage/PhabricatorPHID.php | 5 ----- 2 files changed, 7 deletions(-) diff --git a/src/applications/celerity/resources/CelerityResources.php b/src/applications/celerity/resources/CelerityResources.php index b7c5cc2486..9536786a6a 100644 --- a/src/applications/celerity/resources/CelerityResources.php +++ b/src/applications/celerity/resources/CelerityResources.php @@ -5,8 +5,6 @@ */ abstract class CelerityResources extends Phobject { - private $map; - abstract public function getName(); abstract public function getResourceData($name); diff --git a/src/applications/phid/storage/PhabricatorPHID.php b/src/applications/phid/storage/PhabricatorPHID.php index 7acacc9475..f47d3c819f 100644 --- a/src/applications/phid/storage/PhabricatorPHID.php +++ b/src/applications/phid/storage/PhabricatorPHID.php @@ -2,11 +2,6 @@ final class PhabricatorPHID extends Phobject { - protected $phid; - protected $phidType; - protected $ownerPHID; - protected $parentPHID; - public static function generateNewPHID($type, $subtype = null) { if (!$type) { throw new Exception(pht('Can not generate PHID with no type.')); From 868ee3ef2fd1f4993c1df7e5e6c7002f136ed98e Mon Sep 17 00:00:00 2001 From: lkassianik Date: Wed, 17 Jun 2015 08:12:01 -0700 Subject: [PATCH 2/4] Only evaluate tokens if phids not null Summary: Fixes T8577, Only evaluate tokens if phids not null Test Plan: Open Upcoming Events in Calendar. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8577 Differential Revision: https://secure.phabricator.com/D13326 --- .../calendar/query/PhabricatorCalendarEventSearchEngine.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php index d67c3b1589..0dc4d569f1 100644 --- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php +++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php @@ -127,14 +127,14 @@ final class PhabricatorCalendarEventSearchEngine } $invited_phids = $saved->getParameter('invitedPHIDs'); - $invited_phids = $user_datasource->evaluateTokens($invited_phids); if ($invited_phids) { + $invited_phids = $user_datasource->evaluateTokens($invited_phids); $query->withInvitedPHIDs($invited_phids); } $creator_phids = $saved->getParameter('creatorPHIDs'); - $creator_phids = $user_datasource->evaluateTokens($creator_phids); if ($creator_phids) { + $creator_phids = $user_datasource->evaluateTokens($creator_phids); $query->withCreatorPHIDs($creator_phids); } From af8ad58e6bb1aa5c8a927dbd3e32882c8641ff76 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 17 Jun 2015 10:43:25 -0700 Subject: [PATCH 3/4] Probably fix notifications not being properly marked as unread Summary: Fixes T8586. This wasn't quite right in D13320. Test Plan: iiam Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8586 Differential Revision: https://secure.phabricator.com/D13331 --- .../editor/PhabricatorApplicationTransactionEditor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index fd547c4049..ea541e3cdc 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -1058,7 +1058,7 @@ abstract class PhabricatorApplicationTransactionEditor $mailed = array(); foreach ($messages as $mail) { foreach ($mail->buildRecipientList() as $phid) { - $mailed[$phid] = true; + $mailed[$phid] = $phid; } } From 984976ce2029619fd4d32c94d55e45e2bf6c7a2b Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 17 Jun 2015 10:43:44 -0700 Subject: [PATCH 4/4] Cache viewer spaces Summary: Ref T8575. Although we cache spaces as a whole, we don't cache viewer spaces. This can still do a lot of work if they have complex policies. Instead, cache them in the request cache. Test Plan: Saw this account for 37% of a page in produciton (303ms on on 835ms). Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8575 Differential Revision: https://secure.phabricator.com/D13324 --- .../query/PhabricatorSpacesNamespaceQuery.php | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php b/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php index 65ac146bd0..96125b6aef 100644 --- a/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php +++ b/src/applications/spaces/query/PhabricatorSpacesNamespaceQuery.php @@ -5,6 +5,7 @@ final class PhabricatorSpacesNamespaceQuery const KEY_ALL = 'spaces.all'; const KEY_DEFAULT = 'spaces.default'; + const KEY_VIEWER = 'spaces.viewer'; private $ids; private $phids; @@ -141,17 +142,25 @@ final class PhabricatorSpacesNamespaceQuery } 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;