From df6c315ace5feccd99e073c68d4f82f11724954f Mon Sep 17 00:00:00 2001 From: bob Date: Mon, 14 Aug 2023 10:54:37 +0200 Subject: [PATCH] Fix a PHP 8.1/8.2 deprecated use of strlen deprecated call with a NULL argument 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. Reviewers: O1 Blessed Committers, Matthew Reviewed By: O1 Blessed Committers, Matthew Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15599 Differential Revision: https://we.phorge.it/D25383 --- src/workflow/ArcanistWorkflow.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index 3a855025..d0863772 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -479,8 +479,8 @@ abstract class ArcanistWorkflow extends Phobject { // If we have `token`, this server supports the simpler, new-style // token-based authentication. Use that instead of all the certificate // stuff. - $token = idx($credentials, 'token', ''); - if (strlen($token)) { + $token = idx($credentials, 'token'); + if (phutil_nonempty_string($token)) { $conduit = $this->getConduit(); $conduit->setConduitToken($token); @@ -2244,8 +2244,8 @@ abstract class ArcanistWorkflow extends Phobject { protected function getModernUnitDictionary(array $map) { $map = $this->getModernCommonDictionary($map); - $details = idx($map, 'userData', ''); - if (strlen($details)) { + $details = idx($map, 'userData'); + if (phutil_nonempty_string($details)) { $map['details'] = (string)$details; } unset($map['userData']);