@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+8
+8
src/applications/feed/query/PhabricatorFeedQuery.php
··· 18 18 return $this; 19 19 } 20 20 21 + /** 22 + * @param int|null $range_min Minimum epoch value of feed stories 23 + * @param int|null $range_max Maximum epoch value of feed stories 24 + */ 21 25 public function withEpochInRange($range_min, $range_max) { 26 + if ($range_min && $range_max && $range_min > $range_max) { 27 + throw new PhutilArgumentUsageException( 28 + pht('Feed query minimum range must be lower than maximum range.')); 29 + } 22 30 $this->rangeMin = $range_min; 23 31 $this->rangeMax = $range_max; 24 32 return $this;