Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering project's Configure Menu page
ClosedPublic

Authored by aklapper on May 1 2023, 23:01.

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 T15327

Test Plan

Applied this change (on top of D25166) and /project/1/item/configure/ rendered in web browser.

Diff Detail

Repository
rP Phorge
Branch
T15327 (branched from master)
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 330
Build 330: arc lint + arc unit

Unit TestsFailed

TimeTest
199 msPhabricatorProjectCoreTestCase::testAncestorMembers
EXCEPTION (RuntimeException): Implicit conversion from float 178.5 to int loses precision #0 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(192): PhutilErrorHandler::handleError(8192, '...', '...', 192) #1 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(148): PhabricatorFilesComposeAvatarBuiltinFile::rgba2gd(Array)
65 msPhabricatorProjectCoreTestCase::testJoinLeaveProject
EXCEPTION (RuntimeException): Implicit conversion from float 178.5 to int loses precision #0 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(192): PhutilErrorHandler::handleError(8192, '...', '...', 192) #1 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(148): PhabricatorFilesComposeAvatarBuiltinFile::rgba2gd(Array)
161 msPhabricatorProjectCoreTestCase::testMemberMaterialization
EXCEPTION (RuntimeException): Implicit conversion from float 76.50000000000001 to int loses precision #0 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(192): PhutilErrorHandler::handleError(8192, '...', '...', 192) #1 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(148): PhabricatorFilesComposeAvatarBuiltinFile::rgba2gd(Array)
104 msPhabricatorProjectCoreTestCase::testMilestoneMembership
EXCEPTION (RuntimeException): Implicit conversion from float 178.5 to int loses precision #0 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(192): PhutilErrorHandler::handleError(8192, '...', '...', 192) #1 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(148): PhabricatorFilesComposeAvatarBuiltinFile::rgba2gd(Array)
111 msPhabricatorProjectCoreTestCase::testParentProject
EXCEPTION (RuntimeException): Implicit conversion from float 76.50000000000001 to int loses precision #0 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(192): PhutilErrorHandler::handleError(8192, '...', '...', 192) #1 /var/www/html/phorge/phorge/src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php(148): PhabricatorFilesComposeAvatarBuiltinFile::rgba2gd(Array)
View Full Test Results (7 Failed · 23 Passed)

Event Timeline

aklapper requested review of this revision.May 1 2023, 23:01

Thanks for this patch again!

I tested the $name locally intensively with phlog() to verify that it assumes just null or native string.

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

(The errors in the unit tests are totally unrelated and this will be discussed in T15334)

✅ green light and thanks

sgtm

This revision is now accepted and ready to land.May 3 2023, 10:24