From c553692d452b764d2877469c5639812384634828 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sat, 10 Jun 2023 22:58:10 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception which blocks rendering errors on Create Blueprint page 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=master, ref.master=e4fd31ec024e), phorge(head=D25240, ref.master=b1edfea09bad, ref.D25240=b1edfea09bad) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php:392] ``` Closes T15413 Test Plan: Applied this change on top of D25239. Afterwards, the "Create Blueprint" page on `/drydock/blueprint/edit/form/default/` after pressing the "Create Blueprint" button the page correctly renders the expected error that some fields cannot be empty. # Enter a commit message. # # Changes: # # src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php Also, try to create extra numeric fields (like in the User application) and try to send zero or 1 using Conduit `user.edit`. Reviewers: O1 Blessed Committers, valerio.bozzolan, speck Reviewed By: O1 Blessed Committers, valerio.bozzolan, speck Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15413 Differential Revision: https://we.phorge.it/D25240 --- .../customfield/standard/PhabricatorStandardCustomField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php index 4c0bce861b..c41148a4aa 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php @@ -389,7 +389,7 @@ abstract class PhabricatorStandardCustomField if (is_array($value)) { return empty($value); } - return !strlen($value); + return $value === null || !strlen($value); } public function getApplicationTransactionTitle(