From 92b73fed6b2cb98b9e262462faac88faf4108263 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 3 Jul 2015 10:59:48 -0700 Subject: [PATCH] Don't apply space constraints to omnipotent-viewer queries Summary: Fixes T8743. Fixes T8746. When running queries with the omnipotent viewer and no explicit space constraints, don't add implicit space constraints. This prevents us from fataling when running older pre-space migrations and trying to load space-aware objects. Test Plan: Manually ran migrations with `--trace`, verified no `WHERE spacePHID = ...`. Reviewers: btrahan, chad Reviewed By: chad Subscribers: eadler, epriestley Maniphest Tasks: T8743, T8746 Differential Revision: https://secure.phabricator.com/D13542 --- .../policy/PhabricatorCursorPagedPolicyAwareQuery.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index 772be350a9..f062672783 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -1763,6 +1763,16 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery $viewer = $this->getViewer(); + // If we have an omnipotent viewer and no formal space constraints, don't + // emit a clause. This primarily enables older migrations to run cleanly, + // without fataling because they try to match a `spacePHID` column which + // does not exist yet. See T8743, T8746. + if ($viewer->isOmnipotent()) { + if ($this->spaceIsArchived === null && $this->spacePHIDs === null) { + return null; + } + } + $space_phids = array(); $include_null = false;