Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering "Browse Dashboards" dialog
ClosedPublic

Authored by aklapper on May 13 2023, 11:24.

Details

Summary

strlen() was used in Phabricator to check if a generic value is a non-empty string.

But, that function does not accept null anymore since PHP 8.1.

Closes T15396

Test Plan

Applied this change (on top of D25179 and D25226) and the "Browse Dashboards" dialog got rendered in web browser.

Diff Detail

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

Unit TestsFailed

TimeTest
1 msPhutilSearchQueryCompilerTestCase::testCompileQueries
Assertion failed, expected values to be equal (at PhutilSearchQueryCompilerTestCase.php:268): Compilation of query: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx…
107 msPhabricatorCelerityTestCase::testCelerityMaps
1 assertion passed.
12 msPhabricatorConduitTestCase::testConduitMethods
1 assertion passed.
0 msPhabricatorInfrastructureTestCase::testApplicationsInstalled
1 assertion passed.
0 msPhabricatorInfrastructureTestCase::testRejectMySQLNonUTF8Queries
1 assertion passed.
View Full Test Results (1 Failed · 11 Passed)

Event Timeline

valerio.bozzolan added inline comments.
src/applications/search/compiler/PhutilSearchQueryCompiler.php
107

Wow, finally a place where strlen() was really needed!

Please just do something like this before the strlen:

if($query === null) {
  $query = '';
}
This revision now requires changes to proceed.May 13 2023, 22:54

Uh, that unit test was useful indeed, and I know understand the rest of the code.

Thanks for your update

I tested this locally without any implosion even if I was honestly not able to reproduce a null case while visiting the /dashboard/ page. Anyway, this is 100% legit to me.

lgtm

(#WikimediaHackaton)

This revision is now accepted and ready to land.May 19 2023, 08:54