Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception when DarkConsole is enabled
ClosedPublic

Authored by aklapper on May 4 2023, 15:34.

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.

This is not visible in the web user interface, only in the PHP error log.

Closes T15344

Test Plan

Applied this change, on top of D25165 locally applied, and no stacktrace is printed anymore in the PHP error log.

Diff Detail

Repository
rP Phorge
Branch
arcpatch-D25188
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 363
Build 363: arc lint + arc unit

Event Timeline

aklapper requested review of this revision.May 4 2023, 15:34

Thanks for this patch, again

I tested this change locally with "darkconsole.enabled": true in my conf/local/local.json.

I verified with phlog($visible) the possible incoming values, opening and closing the DarkConsole, triggering it with the backtick keyboard key. I confirm that it only assumes strings ("0" or "1") and null.

Also premising that AphrontRequest#getStr() always return a string or null.

The function phutil_nonempty_string() will report any other alien value, and that is OK.

Hoping to be useful I will also add a small inline comment to clarify the incoming expected values for future hackers.

sgtm

This revision is now accepted and ready to land.May 5 2023, 12:20

hoping to be somehow useful, add a small inline comment