Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering MFA Provider page
ClosedPublic

Authored by aklapper on May 12 2023, 16:50.
Tags
None
Referenced Files
F2148062: D25218.diff
Fri, Apr 19, 06:11
Unknown Object (File)
Wed, Apr 17, 06:13
Unknown Object (File)
Tue, Apr 16, 21:08
Unknown Object (File)
Tue, Apr 16, 07:52
Unknown Object (File)
Thu, Apr 11, 00:41
Unknown Object (File)
Sun, Apr 7, 05:29
Unknown Object (File)
Mon, Apr 1, 01:38
Unknown Object (File)
Mon, Apr 1, 01:38

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 T15386

Test Plan

Applied this change, afterwards page "Mobile Phone App (TOTP)" at /auth/mfa/4/ renders in web browser.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Thanks again for this patch! Tested locally with and without an "enroll message".

Interestingly I was not able to understand what the hell "enroll" means and where this message is shown apart from this Configuration page. For example in the frontend here is not shown:

MFA Frontend message.png (285×838 px, 23 KB)

But, this seems perfectly OK to me. The function phutil_nonempty_string() will explode for any alien type that is not a string or not null. And that is OK here.

sgtm

This revision is now accepted and ready to land.May 20 2023, 08:16

Oh nice, I was able to test the enroll message:

Phorge enroll message test.png (303×620 px, 14 KB)

That is shown during the very first setup of MFA from personal settings