Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering a project's page when Reports prototype enabled
ClosedPublic

Authored by aklapper on May 6 2023, 13:33.

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 exactly the same case as D25140.

Closes T15360

Test Plan

Applied this change and /project/view/1/ rendered the workboard in the web browser as expected.

Diff Detail

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

Unit TestsFailed

TimeTest
175 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)
78 msPhabricatorProjectCoreTestCase::testColumnExtendedPolicies
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)
82 msPhabricatorProjectCoreTestCase::testIsViewerMemberOrWatcher
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)
92 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)
120 msPhabricatorProjectCoreTestCase::testParentProject
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)
View Full Test Results (6 Failed · 24 Passed)

Event Timeline

aklapper requested review of this revision.May 6 2023, 13:33
aklapper retitled this revision from Fix PHP 8.1 "strlen(null)" exception[s] which block rendering the XXXX page to Fix PHP 8.1 "strlen(null)" exception which blocks rendering a project's page when Reports prototype enabled.May 6 2023, 13:34

Thanks for this patch

I tested this locally logging $name and I confirm the bind between that and the menu name, that so it's a string or null (default).

The function phutil_nonempty_string() will report alien values, and that is OK here.

The lint errors are TOTALLY UNRELATED and related to T15334: PhabricatorProjectCoreTestCase: fix "Implicit conversion from float "

This revision is now accepted and ready to land.May 8 2023, 11:51