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.

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