Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" and preg_match() exceptions which block rendering "Browse Subscribers" overlay dialog

Authored by aklapper on May 10 2023, 14:46.
Referenced Files
F2231433: D25214.1718744254.diff
Mon, Jun 17, 20:57
F2231195: D25214.1718694613.diff
Mon, Jun 17, 07:10
Unknown Object (File)
Sat, Jun 15, 12:59
Unknown Object (File)
Wed, Jun 12, 15:27
Unknown Object (File)
Wed, Jun 12, 01:49
Unknown Object (File)
Mon, Jun 10, 17:07
Unknown Object (File)
Mon, Jun 10, 06:09
Unknown Object (File)
Thu, May 30, 11:36



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.

Similarly, preg_match() does not accept passing null as $subject parameter since PHP 8.1.

Closes T15381

Test Plan

Applied these two changes (on top of D25179 and D25213), and on the task creation page, after clicking the magnifier icon in the "Subscribers" field, the "Browse Subscribers" overlay dialog got rendered.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

Thanks again

I tested this against the test plan, and on lot of additional pages and fields. No implosions.



✅ I verified the above line

The potential pitfall is: the string "0" is falsy, but that is really intended here.


✅ I verified the above line

The $value contains the search string, or null.

The function phutil_nonempty_string() is designed to report alien types like objects, and that is good here.

This revision is now accepted and ready to land.May 12 2023, 08:00