From 56838c0e3dc28a3df73e8ec3cb69792689717672 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 9 Jul 2020 10:42:42 -0700 Subject: [PATCH] Fix an issue where querying for a large number of projects by slug could paginate incorrectly Summary: See PHI1809. This query may join the "slug" table, but each project may have multiple slugs, and the query does not "GROUP BY" when this join occurs. This may lead to partial result sets and unusual paging behavior. This could likely be caught categorically in `loadAllFromArray()`; I'll adjust this in a followup. Test Plan: A minimal reproduction case is something like: - Give project P slugs: a, b, c. - Give project Q slugs: d. - Query for slugs: a, b, c, d; with limit 2. - Order the query so P returns first. - Expect: P and Q. - Actual: P generates 3 raw rows and the final result is just P with no pagination cursor. Differential Revision: https://secure.phabricator.com/D21399 --- src/applications/project/query/PhabricatorProjectQuery.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php index 96efcfba4b..22e0b59c94 100644 --- a/src/applications/project/query/PhabricatorProjectQuery.php +++ b/src/applications/project/query/PhabricatorProjectQuery.php @@ -656,6 +656,11 @@ final class PhabricatorProjectQuery if ($this->memberPHIDs || $this->watcherPHIDs || $this->nameTokens) { return true; } + + if ($this->slugs) { + return true; + } + return parent::shouldGroupQueryResultRows(); }