From 6f21c92718eb4cc74f4dd68efc4accfd5a625209 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 23 Oct 2025 23:54:28 +0200 Subject: [PATCH] Check if PhabricatorHash::digestForIndex() receives null Summary: Do not crash with an error passing down null by introducing a check. ``` ERROR 8192: sha1(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/hosts/__PHABRICATOR__/phabricator/src/infrastructure/util/PhabricatorHash.php:47] ``` Refs T16284 Test Plan: Somehow make `idx($_SERVER, 'REMOTE_ADDR')` return `null`, I guess. Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T16284 Differential Revision: https://we.phorge.it/D26458 --- src/infrastructure/util/PhabricatorHash.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/util/PhabricatorHash.php b/src/infrastructure/util/PhabricatorHash.php index 7c49703553..ade43b04a2 100644 --- a/src/infrastructure/util/PhabricatorHash.php +++ b/src/infrastructure/util/PhabricatorHash.php @@ -39,11 +39,14 @@ final class PhabricatorHash extends Phobject { * This method emphasizes compactness, and should not be used for security * related hashing (for general purpose hashing, see @{method:digest}). * - * @param string $string Input string. + * @param string|null $string Input string. * @return string 12-byte, case-sensitive, mostly-alphanumeric hash of * the string. */ public static function digestForIndex($string) { + if ($string === null) { + $string = ''; + } $hash = sha1($string, $raw_output = true); static $map; -- 2.51.2