From 26d74ccc7c26b44872d63360322de72584586a5e Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Wed, 24 May 2023 18:08:40 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception which blocks deleting Phriction document 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. Closes T15419 Test Plan: Applied this changes and page at `/w/` correctly rendered saying `Document Deleted - This document has been deleted. You can edit it to put new content here, or use history to revert to an earlier version.` Also test creating it again, and updating it again: it still works. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15419 Differential Revision: https://we.phorge.it/D25243 --- .../phriction/editor/PhrictionTransactionEditor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/phriction/editor/PhrictionTransactionEditor.php b/src/applications/phriction/editor/PhrictionTransactionEditor.php index 1476b24c46..d59541c401 100644 --- a/src/applications/phriction/editor/PhrictionTransactionEditor.php +++ b/src/applications/phriction/editor/PhrictionTransactionEditor.php @@ -556,7 +556,7 @@ final class PhrictionTransactionEditor ->setContent($this->getOldContent()->getContent()) ->setDescription(''); - if (strlen($this->getDescription())) { + if (phutil_nonempty_string($this->getDescription())) { $content->setDescription($this->getDescription()); }