mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-22 19:49:02 +01:00
Check that min epoch < max epoch in PhabricatorFeedQuery::withEpochInRange()
Summary: `PhabricatorFeedQuery::withEpochInRange()` returns zero results when passing parameters in the wrong order. Instead return a PhutilArgumentUsageException which makes it clear why there are no results. Test Plan: On an early morning without coffee supply, write custom code like ``` $query = id(new PhabricatorFeedQuery()) ->setViewer(PhabricatorUser::getOmnipotentUser()) ->withFilterPHIDs(array($user->getPHID())) ->withEpochInRange(time(), time() - 86400) ->setReturnPartialResultsOnOverheat(true); $stories = $query->execute(); ``` and wonder why you get zero results. Optionally, feel stupid for a moment. Apply patch, now get an "Unhandled Exception ("PhutilArgumentUsageException") - Minimum range must be lower than maximum range." Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25891
This commit is contained in:
parent
fd6118bfa6
commit
abeeadd6b0
1 changed files with 8 additions and 0 deletions
|
@ -18,7 +18,15 @@ final class PhabricatorFeedQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int|null $range_min Minimum epoch value of feed stories
|
||||||
|
* @param int|null $range_max Maximum epoch value of feed stories
|
||||||
|
*/
|
||||||
public function withEpochInRange($range_min, $range_max) {
|
public function withEpochInRange($range_min, $range_max) {
|
||||||
|
if ($range_min && $range_max && $range_min > $range_max) {
|
||||||
|
throw new PhutilArgumentUsageException(
|
||||||
|
pht('Feed query minimum range must be lower than maximum range.'));
|
||||||
|
}
|
||||||
$this->rangeMin = $range_min;
|
$this->rangeMin = $range_min;
|
||||||
$this->rangeMax = $range_max;
|
$this->rangeMax = $range_max;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
Loading…
Add table
Reference in a new issue