Page MenuHomePhorge

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

Authored by aklapper on Wed, Feb 19, 10:15.
Tags
None
Referenced Files
F2992406: D25891.1740213384.diff
Fri, Feb 21, 08:36
F2992405: D25891.1740213383.diff
Fri, Feb 21, 08:36
F2992404: D25891.1740213382.diff
Fri, Feb 21, 08:36
F2992384: D25891.1740211707.diff
Fri, Feb 21, 08:08
F2992382: D25891.1740211444.diff
Fri, Feb 21, 08:04
F2988349: D25891.1740147305.diff
Thu, Feb 20, 14:15
F2986195: D25891.1740096674.diff
Thu, Feb 20, 00:11
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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Wed, Feb 19, 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.