From a65061ddc33da26a203d3a7b73ff0e491a5b9788 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sat, 9 Sep 2023 20:54:44 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception rendering Task with empty custom date field 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=df6c315ace5f, ref.customOAuthUrlencodeNull=c69b9749027f), phorge(head=master, ref.master=7868ab3754fa) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php:14] ``` Closes T15632 Test Plan: Have a custom field with type=date defined in maniphest.custom-field-definitions and edit an existing Task changing something else, keeping that field as empty. Reviewers: O1 Blessed Committers, Sten, valerio.bozzolan Reviewed By: O1 Blessed Committers, Sten, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15632 Differential Revision: https://we.phorge.it/D25431 --- .../customfield/standard/PhabricatorStandardCustomFieldDate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php index eaaa301160..ca56816b42 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php @@ -11,7 +11,7 @@ final class PhabricatorStandardCustomFieldDate $indexes = array(); $value = $this->getFieldValue(); - if (strlen($value)) { + if (phutil_nonempty_scalar($value)) { $indexes[] = $this->newNumericIndex((int)$value); }