1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 08:12:40 +01:00

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
This commit is contained in:
Valerio Bozzolan 2023-05-20 19:17:43 +02:00
parent 524dc83b4e
commit c1c7699c98

View file

@ -124,6 +124,9 @@ final class DarkConsoleCore extends Phobject {
} else if (is_resource($data)) {
return '<resource>';
} 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);