Page MenuHomePhorge

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

Authored by aklapper on May 9 2023, 21:09.
Tags
None
Referenced Files
F2232105: D25211.1718845060.diff
Wed, Jun 19, 00:57
Unknown Object (File)
Sat, Jun 15, 12:59
Unknown Object (File)
Fri, Jun 14, 18:17
Unknown Object (File)
Fri, Jun 14, 11:16
Unknown Object (File)
Wed, Jun 12, 11:00
Unknown Object (File)
Tue, Jun 11, 10:11
Unknown Object (File)
Mon, Jun 10, 17:01
Unknown Object (File)
Fri, Jun 7, 00:43

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.

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

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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

Thanks

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

lgtm

src/applications/settings/panel/PhabricatorEmailAddressesSettingsPanel.php
188

💚 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.May 10 2023, 05:46