Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks rendering Notifications' Advanced Search page
ClosedPublic

Authored by aklapper on May 1 2023, 17:20.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 10, 21:22
Unknown Object (File)
Wed, Apr 10, 17:46
Unknown Object (File)
Mon, Apr 8, 04:24
Unknown Object (File)
Sat, Apr 6, 02:01
Unknown Object (File)
Fri, Apr 5, 17:55
Unknown Object (File)
Mon, Apr 1, 01:26
Unknown Object (File)
Sun, Mar 31, 03:09
Unknown Object (File)
Sat, Mar 30, 06: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 T15320

Test Plan

Applied this change and /notification/query/advanced/ rendered in web browser.

Diff Detail

Repository
rP Phorge
Branch
whateverErrorComesNext (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 323
Build 323: arc lint + arc unit

Event Timeline

aklapper requested review of this revision.May 1 2023, 17:20

Thanks

Tested locally with / without the Notification checkbox. No implosions.

I also tested this on the advanced search on my Maniphest Tasks with custom boolean fields but that seems unrelated since the filters are "(Any)" and "(Require)" in that case. This confusing filter is not specific to this change, but it can be discussed here: T15177: Allow to query Tasks with a custom boolean field set to false

Ready to land.

yesyes

src/applications/search/engine/PhabricatorApplicationSearchEngine.php
875

✅ I tested $request->getStr($key) locally with phlog() and it seems it only assumes null or the string "1". It should never assume the integer 1 to me, since the method getStr() is supposed to cast to string.

The phutil_nonempty_string() will report any alien type (like integers), and that is OK.

This revision is now accepted and ready to land.May 1 2023, 19:45