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.
Tags
None
Referenced Files
F3294141: D25227.1742929716.diff
Mon, Mar 24, 19:08
F3293972: D25227.1742927019.diff
Mon, Mar 24, 18:23
F3284103: D25227.1742767040.diff
Sat, Mar 22, 21:57
F3264127: D25227.1742513053.diff
Wed, Mar 19, 23:24
F3252558: D25227.1742393241.diff
Tue, Mar 18, 14:07
F3252017: D25227.1742386986.diff
Tue, Mar 18, 12:23
F3224959: D25227.1742089891.diff
Sat, Mar 15, 01:51
F3221856: D25227.1741891774.diff
Wed, Mar 12, 18:49

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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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