Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception listing >100 task search results

Authored by aklapper on Aug 15 2023, 14:19.
Referenced Files
F2324161: D25392.1721743890.diff
Mon, Jul 22, 14:11
F2324160: D25392.1721743889.diff
Mon, Jul 22, 14:11
F2324022: D25392.1721743412.diff
Mon, Jul 22, 14:03
Unknown Object (File)
Sun, Jul 21, 16:59
Unknown Object (File)
Sat, Jul 13, 10:21
Unknown Object (File)
Mon, Jul 8, 23:22
Unknown Object (File)
Sat, Jul 6, 18:49
Unknown Object (File)
Sat, Jul 6, 18:47



strlen() was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts phutil_nonempty_string() as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=df6c315ace5f), phorge(head=master, ref.master=7040bd525764)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/maniphest/query/ManiphestTaskQuery.php:1039]

Closes T15604

Test Plan

Have more than 100 tasks, run a broad search with more than 100 results, try to go to next page of results.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline


I tested this without finding any nuclear implosion. Thanks!

To simplify the test plan it seems you can also manually set "Page Size" to a low number, so to trigger pagination.

Premising I don't understand when the cursors could be "123.PHID-PROJ-abcd", this change seems perfectly OK to me since after explode() indeed we work with strings. Also, the element is always available since line 1035.

Probably just if(!$parts[1]) would be enough since it's supposed to be a PHID but I'm not bold enough to recommend it here, because of my previous assertion.


This revision is now accepted and ready to land.Aug 16 2023, 04:02

Right... I also quickly tested with Conduit: On http://phorge.localhost/conduit/method/ entering integer values like 12 or 91 in the fields before, after, limit and this one-liner doesn't show an exception anymore. And same for older http://phorge.localhost/conduit/method/maniphest.query/ and the fields limit and offset there - no exceptions.