Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception which blocks creating a project with an empty Description field
Needs ReviewPublic

Authored by aklapper on May 2 2023, 19:20.
Referenced Files
Unknown Object (File)
Wed, May 31, 06:33
Unknown Object (File)
Fri, May 26, 23:28
Unknown Object (File)
Fri, May 26, 23:17
Unknown Object (File)
Tue, May 23, 22:21
Unknown Object (File)
Sun, May 21, 16:54
Unknown Object (File)
Sun, May 21, 11:32
Unknown Object (File)
Thu, May 18, 02:13
Unknown Object (File)
Thu, May 18, 01:35



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 first half of T15331

Test Plan

Applied these two changes (one in Arcanist, one in Phorge). Project with empty Description field was created and /project/view/projectid/ rendered in web browser.

Diff Detail

rARC Arcanist
Lint Passed
Tests Passed
Build Status
Buildable 411
Build 411: arc lint + arc unit

Event Timeline

aklapper requested review of this revision.May 2 2023, 19:20

Thanks for this patch.

This needs the usual stringlike() trick to make Phorge happy

Also it probably needs the phlog() trick suggested by avivey to make O1 happy

I would say, let's wait for what happens in D25157, then let's turn back here

I'm sorry for this waiting


The already existing PHPDoc was wrong.

The $corpus parameter is not necessarily a string but can be a PhutilSafeHTML as can be see at line 928


Sadly it seems using phutil_nonempty_string() in this case can crash since $corpus can be an object.

We probably need the phutil_nonempty_stringlike() trick instead.


Interestingly this line highlights that $corpus is not always a string

This revision now requires changes to proceed.May 3 2023, 09:38

Use phutil_nonempty_stringlike; update doc comment.

Not sure if some additional phlog code is wanted or needed here - what exactly do we want to find out, apart from string and PhutilSafeHTML being input types?

Accepting (but not as O1) since this seems totally legit to me now. Thanks for your update

I don't approve as O1 because I know probably somebody would like to share different opinions.