@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Cache application visibility in the request cache

Summary: Ref T8575. We check if users can see applications frequently, and caching on the Query isn't especially effective. Use the new Request cache instead.

Test Plan:
- Saw `/feed/` drop 7% (from ~830ms to ~770ms) on profiles.

Reviewers: btrahan, avivey

Reviewed By: avivey

Subscribers: avivey, epriestley

Maniphest Tasks: T8575

Differential Revision: https://secure.phabricator.com/D13321

+22 -20
+17 -6
src/applications/base/PhabricatorApplication.php
··· 449 449 $class, 450 450 PhabricatorUser $viewer) { 451 451 452 - if (!self::isClassInstalled($class)) { 453 - return false; 452 + $cache = PhabricatorCaches::getRequestCache(); 453 + $viewer_phid = $viewer->getPHID(); 454 + $key = 'app.'.$class.'.installed.'.$viewer_phid; 455 + 456 + $result = $cache->getKey($key); 457 + if ($result === null) { 458 + if (!self::isClassInstalled($class)) { 459 + $result = false; 460 + } else { 461 + $result = PhabricatorPolicyFilter::hasCapability( 462 + $viewer, 463 + self::getByClass($class), 464 + PhabricatorPolicyCapability::CAN_VIEW); 465 + } 466 + 467 + $cache->setKey($key, $result); 454 468 } 455 469 456 - return PhabricatorPolicyFilter::hasCapability( 457 - $viewer, 458 - self::getByClass($class), 459 - PhabricatorPolicyCapability::CAN_VIEW); 470 + return $result; 460 471 } 461 472 462 473
+5 -14
src/infrastructure/query/policy/PhabricatorPolicyAwareQuery.php
··· 35 35 private $workspace = array(); 36 36 private $inFlightPHIDs = array(); 37 37 private $policyFilteredPHIDs = array(); 38 - private $canUseApplication; 39 38 40 39 /** 41 40 * Should we continue or throw an exception when a query result is filtered ··· 679 678 * execute the query. 680 679 */ 681 680 public function canViewerUseQueryApplication() { 682 - if ($this->canUseApplication === null) { 683 - $class = $this->getQueryApplicationClass(); 684 - if (!$class) { 685 - $this->canUseApplication = true; 686 - } else { 687 - $result = id(new PhabricatorApplicationQuery()) 688 - ->setViewer($this->getViewer()) 689 - ->withClasses(array($class)) 690 - ->execute(); 691 - 692 - $this->canUseApplication = (bool)$result; 693 - } 681 + $class = $this->getQueryApplicationClass(); 682 + if (!$class) { 683 + return true; 694 684 } 695 685 696 - return $this->canUseApplication; 686 + $viewer = $this->getViewer(); 687 + return PhabricatorApplication::isClassInstalledForViewer($class, $viewer); 697 688 } 698 689 699 690 }