Page MenuHomePhorge

Fix a PHP 8.1/8.2 deprecated use of strlen deprecated call with a NULL argument

Authored by bob on Aug 10 2023, 16:28.
Referenced Files
Unknown Object (File)
Sun, Jul 21, 17:23
Unknown Object (File)
Sat, Jul 20, 12:25
Unknown Object (File)
Fri, Jul 19, 19:43
Unknown Object (File)
Wed, Jul 17, 06:06
Unknown Object (File)
Tue, Jul 16, 03:18
Unknown Object (File)
Tue, Jul 9, 11:17
Unknown Object (File)
Tue, Jul 9, 11:06
Unknown Object (File)
Tue, Jul 9, 09:37



This strlen call triggering an exception if an user tried to call the patch command without an authentication token
Indeed, strlen() was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1, we use phutil_nonempty_string() as a replacement.

Fix T15599

Test Plan

Remove your arcanist authentication token file (if you have one) and try to call the patch command in a repository.
You should get an error message suggesting you to call the install-certificate command instead of an exception.

Diff Detail

rARC Arcanist
Lint Not Applicable
Tests Not Applicable

Event Timeline

bob requested review of this revision.Aug 10 2023, 16:28

Thanks! Interestingly you fixed an incomplete fix since D25128

It seems that the original patcher had not the array key, so they fixed that case with a default array key value as empty-string. Instead, you have the array key, and it's NULL, so the default array-key is unused and just confusing.

Does this fix your problem, keeping your change as-is, but also rollbacking idx() as before, removing the '' default?


Can you also try simplifing this in this way (keeping phutil_nonempty_string() below)?

Updating D25383: Removing useless fallback string definition when calling idx

bob marked an inline comment as done.Aug 11 2023, 10:36
This revision is now accepted and ready to land.Aug 11 2023, 16:29