From a9cd146745035dd3f597edd57fa0ce78f3ac45ec Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 27 Feb 2017 12:08:54 -0800 Subject: [PATCH] Filter archived packages out of the "controlling packages" query earlier Summary: Ref T12319. Currently, we end up filtering archived packages out once for each path. This shows up on a profile from an install as meaningfully expensive: https://secure.phabricator.com/xhprof/profile/PHID-FILE-7kmpevyr22aih4s2vyln/?symbol=PhabricatorOwnersPackage::isArchived Instead, filter them out before we do any work. Test Plan: Viewed a revision, still saw packages. {F3425553} Reviewers: chad Reviewed By: chad Maniphest Tasks: T12319 Differential Revision: https://secure.phabricator.com/D17427 --- .../query/PhabricatorOwnersPackageQuery.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/applications/owners/query/PhabricatorOwnersPackageQuery.php b/src/applications/owners/query/PhabricatorOwnersPackageQuery.php index d99768acbb..8194dd7a6a 100644 --- a/src/applications/owners/query/PhabricatorOwnersPackageQuery.php +++ b/src/applications/owners/query/PhabricatorOwnersPackageQuery.php @@ -129,7 +129,16 @@ final class PhabricatorOwnersPackageQuery } if ($this->controlMap) { - $this->controlResults += mpull($packages, null, 'getID'); + foreach ($packages as $package) { + // If this package is archived, it's no longer a controlling package + // for any path. In particular, it can not force active packages with + // weak dominion to give up control. + if ($package->isArchived()) { + continue; + } + + $this->controlResults[$package->getID()] = $package; + } } return $packages; @@ -361,13 +370,6 @@ final class PhabricatorOwnersPackageQuery $best_match = null; $include = false; - // If this package is archived, it's no longer a controlling package - // for the given path. In particular, it can not force active packages - // with weak dominion to give up control. - if ($package->isArchived()) { - continue; - } - $repository_paths = $package->getPathsForRepository($repository_phid); foreach ($repository_paths as $package_path) { $strength = $package_path->getPathMatchStrength(