From cb9fcf18d5c33ebce1ab20d9115967e46f0cc205 Mon Sep 17 00:00:00 2001 From: Steve Campbell Date: Mon, 17 Jul 2023 14:39:42 +0100 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception trying to stop maintenance mode of Diffusion repo 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. Use `isset` instead to check if the argument "start" was passed to the CLI command. ``` EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/src/error/PhutilErrorHandler.php:261] arcanist(head=master, ref.master=97e163187418), phorge(head=repoMaintStartHistory, ref.master=1c098c273d06, ref.repoMaintStartHistory=0a4a34143528) #0 PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/applications/repository/management/PhabricatorRepositoryManagementMaintenanceWorkflow.php:45] ``` Closes T15476 Test Plan: After applying this change, executing `./bin/repository maintenance --stop R1` on the CLI shows `Took repository "R1" out of maintenance mode.` as expected, instead of an exception. Reviewers: O1 Blessed Committers, valerio.bozzolan, aklapper, avivey Reviewed By: O1 Blessed Committers, valerio.bozzolan, avivey Subscribers: Sten, avivey, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15476 Differential Revision: https://we.phorge.it/D25296 --- .../PhabricatorRepositoryManagementMaintenanceWorkflow.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementMaintenanceWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementMaintenanceWorkflow.php index 6c2f64b31c..513891c5c6 100644 --- a/src/applications/repository/management/PhabricatorRepositoryManagementMaintenanceWorkflow.php +++ b/src/applications/repository/management/PhabricatorRepositoryManagementMaintenanceWorkflow.php @@ -42,7 +42,7 @@ final class PhabricatorRepositoryManagementMaintenanceWorkflow } $message = $args->getArg('start'); - $is_start = (bool)strlen($message); + $is_start = $message !== null; $is_stop = $args->getArg('stop'); if (!$is_start && !$is_stop) {