From c1c7699c989114f781fbbd2758d219521d1d5303 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Sat, 20 May 2023 19:17:43 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exceptions which block rendering the DarkConsole Summary: Since PHP 8.1 the function call `strlen(null)` is deprecated. Since Phabricator/Phorge elevates deprecation warnings to exceptions, the specific fix implies dealing with null, and dealing with real strings. In the specific case, a simple cast was made to deal with real strings. Closes T15315 Test Plan: Visit the Home Page with DarkConsole enabled in your configuration: no crashes Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: aklapper, speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15315 Differential Revision: https://we.phorge.it/D25165 --- src/applications/console/core/DarkConsoleCore.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/applications/console/core/DarkConsoleCore.php b/src/applications/console/core/DarkConsoleCore.php index 437d6f0be7..73065b900e 100644 --- a/src/applications/console/core/DarkConsoleCore.php +++ b/src/applications/console/core/DarkConsoleCore.php @@ -124,6 +124,9 @@ final class DarkConsoleCore extends Phobject { } else if (is_resource($data)) { return ''; } else { + // This is very probably not a string in strict sense + $data = phutil_string_cast($data); + // Truncate huge strings. Since the data doesn't really matter much, // just truncate bytes to avoid PhutilUTF8StringTruncator overhead. $length = strlen($data);