Skip to content

Commit a65061d

Browse files
committed
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 freebsd#1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261] arcanist(head=customOAuthUrlencodeNull, ref.master=df6c315ace5f, ref.customOAuthUrlencodeNull=c69b9749027f), phorge(head=master, ref.master=7868ab3754fa) #0 <freebsd#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/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
1 parent f7d9d95 commit a65061d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function buildFieldIndexes() {
1111
$indexes = array();
1212

1313
$value = $this->getFieldValue();
14-
if (strlen($value)) {
14+
if (phutil_nonempty_scalar($value)) {
1515
$indexes[] = $this->newNumericIndex((int)$value);
1616
}
1717

0 commit comments

Comments
 (0)