From c61c6a1ec3c1bbfa6c7254ce824bca8a860d4417 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Fri, 11 Aug 2023 21:00:25 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception adding a Harbormaster Build Plan 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. ``` EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/src/error/PhutilErrorHandler.php:261] arcanist(head=customOAuthUrlencodeNull, ref.master=788098096e11, ref.customOAuthUrlencodeNull=4f0f2043b7e9), phorge(head=master, ref.master=226f3150933d) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php:106] ``` Closes T15591 Test Plan: Visit `/harbormaster/plan/edit/form/default/`. "Create Build Plan" page renders as expected. Reviewers: O1 Blessed Committers, Matthew Reviewed By: O1 Blessed Committers, Matthew Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15591 Differential Revision: https://we.phorge.it/D25376 --- .../harbormaster/editor/HarbormasterBuildPlanEditEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php b/src/applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php index c0fa80d71b..b7d73f238b 100644 --- a/src/applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php +++ b/src/applications/harbormaster/editor/HarbormasterBuildPlanEditEngine.php @@ -103,7 +103,7 @@ final class HarbormasterBuildPlanEditEngine $key); $behavior_option = $object->getPlanProperty($storage_key); - if (!strlen($behavior_option)) { + if (!phutil_nonempty_string($behavior_option)) { $behavior_option = $behavior->getPlanOption($object)->getKey(); }