From bab99707405585911ca0e07d52d7117acd08fbcc Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sat, 10 Jun 2023 16:25:56 +0200 Subject: [PATCH] Fix PHP 8.1 "trim(null)" exception which blocks rendering Conduit's harbormaster.sendmessage page Summary: Since PHP 8.1, passing a null string to `trim()` is deprecated. Thus first check that `$content` is not null before trimming it. Also since trim() returns a string and never null, we can also simplify the non-empty check, in a more readable and efficient way, avoiding strlen() that was usually used for other "more wild" cases. ``` EXCEPTION: (RuntimeException) trim(): Passing null to parameter #1 ($string) of type string is deprecated at [/src/error/PhutilErrorHandler.php:261] arcanist(head=master, ref.master=18554ea76ceb), phorge(head=master, ref.master=0d81da590923) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/error/PhutilErrorHandler.php:261] #1 <#2> trim(NULL) called at [/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php:117] ``` Closes T15427 Test Plan: Applied this change, afterwards `/conduit/method/harbormaster.sendmessage/` correctly rendered in web browser. Reviewers: O1 Blessed Committers, speck, valerio.bozzolan Reviewed By: O1 Blessed Committers, speck, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15427 Differential Revision: https://we.phorge.it/D25259 --- .../markup/blockrule/PhutilRemarkupTableBlockRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php b/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php index 72e61881ce..f02b9b7422 100644 --- a/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php +++ b/src/infrastructure/markup/blockrule/PhutilRemarkupTableBlockRule.php @@ -114,7 +114,7 @@ final class PhutilRemarkupTableBlockRule extends PhutilRemarkupBlockRule { if ($cell->isContentNode()) { $content = $node->getContent(); - if (!strlen(trim($content))) { + if ($content === null || trim($content) === '') { continue; }