Page MenuHomePhorge

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

Authored by aklapper on Thu, May 4, 15:34.
Referenced Files
Unknown Object (File)
Wed, May 31, 06:36
Unknown Object (File)
Wed, May 24, 03:45
Unknown Object (File)
Tue, May 23, 13:24
Unknown Object (File)
Mon, May 22, 13:57
Unknown Object (File)
Mon, May 22, 12:54
Unknown Object (File)
Tue, May 16, 01:22



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

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Thu, May 4, 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.


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

hoping to be somehow useful, add a small inline comment