Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception when trying to add empty user email address

Authored by aklapper on Tue, May 9, 21:09.
Referenced Files
F303891: D25211.id707.diff
Thu, Jun 1, 04:42
Unknown Object (File)
Wed, May 31, 06:42
Unknown Object (File)
Tue, May 30, 13:14
Unknown Object (File)
Tue, May 30, 04:45
Unknown Object (File)
Thu, May 25, 20:23



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.

Closes T15377

Test Plan

Applied this change, afterwards repeated the steps to add a new email address on /settings/panel/email/ and left the "Email" field empty. This time, after selecting the "Save" button, the error message "Email is required." is displayed in the "New Address" overlay dialog.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Tue, May 9, 21:09


Tested locally. Adding an email. Adding no email. Multiple fuzz tests. No implosions.



💚 I verifies that the $email comes from AphrontRequest#getStr() that always returns null or a string.

The function phutil_nonempty_string() will report alien types (such as objects), and that extra check is OK here.

This revision is now accepted and ready to land.Wed, May 10, 05:46