From 639bab3f89109edccc5a6f68c8e7e90dc7a43ac8 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 13 Sep 2013 14:13:44 -0700 Subject: [PATCH] fix bin/audit to not query whole DB if no commits found Summary: reported by csilvers in irc Test Plan: ran a bum query with --trace and verified table scan not run Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Differential Revision: https://secure.phabricator.com/D6986 --- ...habricatorAuditManagementDeleteWorkflow.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php b/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php index 67c90ffaf1..a06deea931 100644 --- a/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php +++ b/src/applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php @@ -103,14 +103,16 @@ final class PhabricatorAuditManagementDeleteWorkflow $audits = $query->execute(); $commits = $query->getCommits(); - // TODO: AuditQuery is currently not policy-aware and uses an old query - // to load commits. Load them in the modern way to get repositories. Remove - // this after modernizing PhabricatorAuditQuery. - $commits = id(new DiffusionCommitQuery()) - ->setViewer($viewer) - ->withPHIDs(mpull($commits, 'getPHID')) - ->execute(); - $commits = mpull($commits, null, 'getPHID'); + if ($commits) { + // TODO: AuditQuery is currently not policy-aware and uses an old query + // to load commits. Load them in the modern way to get repositories. + // Remove this after modernizing PhabricatorAuditQuery. + $commits = id(new DiffusionCommitQuery()) + ->setViewer($viewer) + ->withPHIDs(mpull($commits, 'getPHID')) + ->execute(); + $commits = mpull($commits, null, 'getPHID'); + } foreach ($audits as $key => $audit) { $commit = idx($commits, $audit->getCommitPHID());