Page MenuHomePhorge

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

Authored by aklapper on May 10 2023, 14:46.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 26, 08:39
Unknown Object (File)
Tue, Mar 26, 08:39
Unknown Object (File)
Tue, Mar 26, 07:58
Unknown Object (File)
Tue, Mar 26, 07:28
Unknown Object (File)
Mon, Mar 18, 22:50
Unknown Object (File)
Feb 25 2024, 07:37
Unknown Object (File)
Feb 25 2024, 07:37
Unknown Object (File)
Feb 25 2024, 06:54

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.

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

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Thanks again

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

sgtm

src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
30

✅ I verified the above line

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

src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
2452

✅ 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