mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
Fix PHP 8.1 "strlen(null)" exception creating Blueprint Working Copy
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, however use `phutil_nonempty_scalar()` as the value might not necessarily be a string object. Note: this may highlight other absurd input values that might be worth correcting instead of just ignoring. If phutil_nonempty_scalar() 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 [<arcanist>/src/error/PhutilErrorHandler.php:261] arcanist(head=master, ref.master=788098096e11), phorge(head=arcpatch-D25239, ref.master=840a7fab2bc8, ref.arcpatch-D25239=870d62ce0ed9) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php:36] ``` Closes T15581 Test Plan: Page `Create Blueprint` at `/drydock/blueprint/edit/form/default/` renders as expected in web browser. Try also creating a custom integer field and put some fuzzy data. https://we.phorge.it/book/phorge/article/custom_fields/ Test these values: - 1 (stays as-is) - 0 (stays as-is) - 123.45 (becomes 123) - a "lizard" (becomes zero) - empty ("") (becomes empty) Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15581 Differential Revision: https://we.phorge.it/D25371
This commit is contained in:
parent
39b576b145
commit
226f315093
1 changed files with 1 additions and 1 deletions
|
@ -33,7 +33,7 @@ final class PhabricatorStandardCustomFieldInt
|
|||
}
|
||||
|
||||
public function setValueFromStorage($value) {
|
||||
if (strlen($value)) {
|
||||
if (phutil_nonempty_scalar($value)) {
|
||||
$value = (int)$value;
|
||||
} else {
|
||||
$value = null;
|
||||
|
|
Loading…
Reference in a new issue