Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception[s] which block rendering "Browse Projects" overlay dialog
ClosedPublic

Authored by aklapper on May 10 2023, 14:27.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 13, 20:26
Unknown Object (File)
Thu, Apr 11, 09:07
Unknown Object (File)
Thu, Apr 11, 08:50
Unknown Object (File)
Wed, Apr 10, 19:32
Unknown Object (File)
Sun, Apr 7, 10:00
Unknown Object (File)
Sat, Apr 6, 01:33
Unknown Object (File)
Mon, Apr 1, 01:37
Unknown Object (File)
Tue, Mar 26, 08:39

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 T15380

Test Plan

Applied these two changes (on top of D25179) and on the task creation page, after clicking the magnifier icon in the "Tags" field, the "Browse Projects" overlay dialog got rendered.

Diff Detail

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

Unit TestsFailed

TimeTest
95 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)
84 msPhabricatorProjectCoreTestCase::testColumnExtendedPolicies
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)
152 msPhabricatorProjectCoreTestCase::testEditProject
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)
67 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)
244 msPhabricatorProjectCoreTestCase::testJoinLeaveProject
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 (9 Failed · 21 Passed)

Event Timeline

aklapper edited the test plan for this revision. (Show Details)

Thanks (again)

I tested this patch locally following the test plan. No implosions.

Also tested with various Typehead like Subscribers.

sgtm

src/applications/project/typeahead/PhabricatorProjectDatasource.php
86

✅ I verified that the above line just contains a string (or maybe null for some weird cases).

The function phutil_nonempty_string() will report alien types (like objects), and that is OK.

135

✅ Same as above

This revision is now accepted and ready to land.May 11 2023, 16:53

To other reviewers: the related lint errors will be fixed also thanks to aklapper: D25209