Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" and "array_slice(null)" exceptions which block typeahead completion proposals

Authored by aklapper on May 1 2023, 18:09.
Referenced Files
Unknown Object (File)
Wed, May 31, 06:31
Unknown Object (File)
Tue, May 23, 16:18
Unknown Object (File)
Sun, May 21, 19:05
Unknown Object (File)
Sun, May 21, 13:26
Unknown Object (File)
Tue, May 16, 08:24



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.

array_slice() no longer accepts passing null as a parameter.
This behavior is deprecated since PHP 8.1. Adding an if clause; not using a
Null Coalescing Operator (PHP 7+) as Phorge currently still supports PHP 5.5.

Closes T15321

Test Plan

Applied these two changes on top of D25147. Afterwards, typeahead autocompletion
proposal dropdowns for the three fields "Assigned To", "Subscribers", "Tags" got
displayed in web browser.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.May 1 2023, 18:09

Thanks also for this patch.

Tested locally. No implosions.

It would be nice to understand where the parameters are populated, thought. But, this is fortunately probably out of the scope here, since getStr() should do the needed part important to us.



✅ I was honestly not able to completely test the non-null values of $raw_parameters so I have not any idea about the intended semantic usage, but the getStr() method is supposed to return strings, so this seems very OK to me.

The method phutil_nonempty_string() will report any alien type, and this OK there.


✅ FINALLY the IDEAL usage of a simple if() in PHP. Since the value "0" is assumed as false for weird reasons related to PHP, but here it's converted to the numerical 0 and it has LOT of sense.

Thanks for this.

This revision is now accepted and ready to land.May 1 2023, 20:07