mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
Fix PHP 8.1 "strlen(null)" exceptions handling empty comment metadata in PhabricatorEditEngine
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. ``` ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/transactions/editengine/PhabricatorEditEngine.php:1923] ``` ``` ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/transactions/editengine/PhabricatorEditEngine.php:2023] ``` Closes T15864 Test Plan: See steps in https://we.phorge.it/T15864 Reviewers: O1 Blessed Committers, speck Reviewed By: O1 Blessed Committers, speck Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15864 Differential Revision: https://we.phorge.it/D25699
This commit is contained in:
parent
68762e8204
commit
5a9cf81ae5
1 changed files with 2 additions and 2 deletions
|
@ -1920,7 +1920,7 @@ abstract class PhabricatorEditEngine
|
||||||
$comment_text = $request->getStr('comment');
|
$comment_text = $request->getStr('comment');
|
||||||
|
|
||||||
$comment_metadata = $request->getStr('comment_metadata');
|
$comment_metadata = $request->getStr('comment_metadata');
|
||||||
if (strlen($comment_metadata)) {
|
if (phutil_nonempty_string($comment_metadata)) {
|
||||||
$comment_metadata = phutil_json_decode($comment_metadata);
|
$comment_metadata = phutil_json_decode($comment_metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2020,7 +2020,7 @@ abstract class PhabricatorEditEngine
|
||||||
$xactions[] = $xaction;
|
$xactions[] = $xaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($comment_text) || !$xactions) {
|
if (phutil_nonempty_string($comment_text) || !$xactions) {
|
||||||
$xactions[] = id(clone $template)
|
$xactions[] = id(clone $template)
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||||
->setMetadataValue('remarkup.control', $comment_metadata)
|
->setMetadataValue('remarkup.control', $comment_metadata)
|
||||||
|
|
Loading…
Reference in a new issue