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.

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
Branch
addEmptyOwnNewEmailAd (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 388
Build 388: arc lint + arc unit

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