From ad77f117f036b30aa9479e749f59ee7d5fdee0c7 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Fri, 22 Aug 2025 11:40:40 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exceptions in /bin/auth revoke 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. ``` ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/auth/management/PhabricatorAuthManagementRevokeWorkflow.php:122] ``` Closes T16227 Test Plan: * Run `./bin/auth revoke --type ssh` * Run `./bin/auth revoke --type '' --everything` Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T16227 Differential Revision: https://we.phorge.it/D26276 --- .../management/PhabricatorAuthManagementRevokeWorkflow.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/applications/auth/management/PhabricatorAuthManagementRevokeWorkflow.php b/src/applications/auth/management/PhabricatorAuthManagementRevokeWorkflow.php index f2a9e35688..efcd115291 100644 --- a/src/applications/auth/management/PhabricatorAuthManagementRevokeWorkflow.php +++ b/src/applications/auth/management/PhabricatorAuthManagementRevokeWorkflow.php @@ -71,7 +71,7 @@ final class PhabricatorAuthManagementRevokeWorkflow '"--everything". Use "--list" to list available credential '. 'types.')); } - } else if (strlen($type) && $is_everything) { + } else if (phutil_nonempty_string($type) && $is_everything) { throw new PhutilArgumentUsageException( pht( 'Specify the credential type to revoke with "--type" or '. @@ -119,12 +119,12 @@ final class PhabricatorAuthManagementRevokeWorkflow } $target = null; - if (!strlen($from) && !$is_everywhere) { + if (!phutil_nonempty_string($from) && !$is_everywhere) { throw new PhutilArgumentUsageException( pht( 'Specify the target to revoke credentials from with "--from" or '. 'specify "--everywhere".')); - } else if (strlen($from) && $is_everywhere) { + } else if (phutil_nonempty_string($from) && $is_everywhere) { throw new PhutilArgumentUsageException( pht( 'Specify the target to revoke credentials from with "--from" or '. -- 2.51.2