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
Unknown Object (File)
Sat, Jun 15, 12:59
Unknown Object (File)
Sat, Jun 8, 18:00
Unknown Object (File)
Sat, Jun 8, 15:57
Unknown Object (File)
Sat, Jun 8, 06:15
Unknown Object (File)
Tue, Jun 4, 22:31
Unknown Object (File)
Tue, Jun 4, 16:22
Unknown Object (File)
Fri, May 31, 20:07
Unknown Object (File)
Thu, May 30, 11:36

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