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
F3575537: D25891.1745004716.diff
Thu, Apr 17, 19:31
F3571862: D25891.1744998922.diff
Thu, Apr 17, 17:55
F3513358: D25891.1744807997.diff
Tue, Apr 15, 12:53
F3477939: D25891.1744762323.diff
Tue, Apr 15, 00:12
F3393233: D25891.1744497071.diff
Fri, Apr 11, 22:31
F3390699: D25891.1744470804.diff
Fri, Apr 11, 15:13
F3388305: D25891.1744446150.diff
Fri, Apr 11, 08:22
F3388304: D25891.1744446143.diff
Fri, Apr 11, 08:22
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.