Page MenuHomePhorge

Check that min epoch < max epoch in PhabricatorFeedQuery::withEpochInRange()
ClosedPublic

Authored by aklapper on Feb 19 2025, 10:15.
Tags
None
Referenced Files
F3300138: D25891.1743034201.diff
Wed, Mar 26, 00:10
F3288867: D25891.1742837086.diff
Sun, Mar 23, 17:24
F3236172: D25891.1742164584.diff
Sat, Mar 15, 22:36
F3225615: D25891.1742140634.diff
Sat, Mar 15, 15:57
F3225344: D25891.1742108467.diff
Sat, Mar 15, 07:01
F3225181: D25891.1742094909.diff
Sat, Mar 15, 03:15
F3223411: D25891.1741948606.diff
Thu, Mar 13, 10:36
F3221766: D25891.1741882188.diff
Wed, Mar 12, 16:09
Tokens
"Love" token, awarded by valerio.bozzolan.

Details

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."

Diff Detail

Repository
rP Phorge
Branch
feedEpochRange (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 1736
Build 1736: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Feb 19 2025, 12:57

Small question. Is it supposed to be used with null+null?

src/applications/feed/query/PhabricatorFeedQuery.php
26

Maybe this, to support null on one, or on the other, from unknown usages / unknown resetters

Uh, nice thought! Phorge accepts and handles correctly one or two parameters being null which I think is fine as-is, so I'd only check for switched parameters created by confused developers here.

Oh wait I totally misunderstood you, sigh

Alright, even after calling ->withEpochInRange(null, null) this very code change (comparing null with null) works fine without a problem, so I'd not add that additional null check

I don't know if anybody is supposed to run

->withEpochInRange(time(), null)

Technically the backend was supporting that, and time > null is true so generates that new exception

Argh, right... That's why I love reviews! :D Thus also check for null.