From 1d8483a9bd850c2e1762d07b1e691a2a6ace88fc Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Wed, 3 May 2023 10:20:24 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception which blocks rendering the "Manage Menu" page 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. However, the parameter `$item_id` is a numeric value when populated. Thus replace `strlen()` with `phutil_nonempty_scalar()` as `phutil_nonempty_string()` could break a Conduit API consumer sending a numeric value. Note: this may highlight other absurd input values that might be worth correcting instead of just ignoring. If phutil_nonempty_scalar() throws an exception in your instance, report it to Phorge to evaluate and fix that specific corner case. Closes T15317 Test Plan: Applied this change and `/home/menu/configure/` rendered in web browser. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15317 Differential Revision: https://we.phorge.it/D25166 --- src/applications/search/engine/PhabricatorProfileMenuEngine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/applications/search/engine/PhabricatorProfileMenuEngine.php b/src/applications/search/engine/PhabricatorProfileMenuEngine.php index 3845c0f127..8799ae8f0b 100644 --- a/src/applications/search/engine/PhabricatorProfileMenuEngine.php +++ b/src/applications/search/engine/PhabricatorProfileMenuEngine.php @@ -135,7 +135,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { if ($is_view) { $selected_item = $this->selectViewItem($view_list, $item_id); } else { - if (!strlen($item_id)) { + if (!phutil_nonempty_scalar($item_id)) { $item_id = self::ITEM_MANAGE; } $selected_item = $this->selectEditItem($view_list, $item_id);