Page MenuHomePhorge

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

Authored by aklapper on Aug 15 2023, 14:19.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 4, 14:18
Unknown Object (File)
Sat, May 4, 14:18
Unknown Object (File)
Sat, May 4, 13:22
Unknown Object (File)
Sat, May 4, 12:33
Unknown Object (File)
Wed, May 1, 19:14
Unknown Object (File)
Wed, May 1, 19:14
Unknown Object (File)
Wed, May 1, 19:14
Unknown Object (File)
Tue, Apr 30, 18:41

Details

Summary

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

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Thanks!

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.

lgtm

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/maniphest.search/ 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.