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
F3648921: D25891.1745434276.diff
Tue, Apr 22, 18:51
F3605176: D25891.1745255688.diff
Sun, Apr 20, 17:14
F3605036: D25891.1745250898.diff
Sun, Apr 20, 15:54
F3585465: D25891.1745129677.diff
Sat, Apr 19, 06:14
F3585464: D25891.1745129669.diff
Sat, Apr 19, 06:14
F3576970: D25891.1745074697.diff
Fri, Apr 18, 14:58
F3575537: D25891.1745004716.diff
Thu, Apr 17, 19:31
F3571862: D25891.1744998922.diff
Thu, Apr 17, 17:55
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 1732
Build 1732: 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.