diff --git a/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php b/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php index 08a793b8b7..2f305ff866 100644 --- a/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php +++ b/src/applications/policy/__tests__/PhabricatorPolicyTestCase.php @@ -133,6 +133,11 @@ final class PhabricatorPolicyTestCase extends PhabricatorTestCase { 2, count($query->setLimit(3)->setOffset(1)->execute()), 'Offsets work correctly.'); + + $this->assertEqual( + 2, + count($query->setLimit(0)->setOffset(1)->execute()), + 'Offset with no limit works.'); } @@ -165,7 +170,6 @@ final class PhabricatorPolicyTestCase extends PhabricatorTestCase { } - /** * Test an object for visibility across multiple user specifications. */ diff --git a/src/infrastructure/query/policy/PhabricatorPolicyQuery.php b/src/infrastructure/query/policy/PhabricatorPolicyQuery.php index d9c29e1350..a1dc23ae26 100644 --- a/src/infrastructure/query/policy/PhabricatorPolicyQuery.php +++ b/src/infrastructure/query/policy/PhabricatorPolicyQuery.php @@ -153,7 +153,11 @@ abstract class PhabricatorPolicyQuery extends PhabricatorOffsetPagedQuery { $limit = (int)$this->getLimit(); $count = 0; - $need = $offset + $limit; + if ($limit) { + $need = $offset + $limit; + } else { + $need = 0; + } $this->willExecute();