Page MenuHomePhorge

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

Authored by bob on Aug 10 2023, 16:28.
Tags
None
Referenced Files
F2945773: D25383.1738361310.diff
Thu, Jan 30, 22:08
F2943901: D25383.1738231333.diff
Wed, Jan 29, 10:02
F2943442: D25383.1738190544.diff
Tue, Jan 28, 22:42
F2942667: D25383.1738125508.diff
Tue, Jan 28, 04:38
F2938283: D25383.1737991680.diff
Sun, Jan 26, 15:28
F2937357: D25383.1737953687.diff
Sun, Jan 26, 04:54
F2936824: D25383.1737940703.diff
Sun, Jan 26, 01:18
F2933514: D25383.1737773136.diff
Fri, Jan 24, 02:45

Details

Summary

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

Repository
rARC Arcanist
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 740
Build 740: arc lint + arc unit

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?

src/workflow/ArcanistWorkflow.php
481–482

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