From 0358ff7ee314f3d96687a2400eb50cdde15d0385 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Mon, 26 Aug 2024 23:40:05 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception in PhutilOAuth1Future 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. ``` ERROR 8192: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/arcanist/src/future/oauth/PhutilOAuth1Future.php:232] ``` Closes T15929 Test Plan: Run `arcanist/bin/arc unit --everything` on a PHP >= 8.1 system. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15929 Differential Revision: https://we.phorge.it/D25811 --- src/future/oauth/PhutilOAuth1Future.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/future/oauth/PhutilOAuth1Future.php b/src/future/oauth/PhutilOAuth1Future.php index f73b9db0..87a819d9 100644 --- a/src/future/oauth/PhutilOAuth1Future.php +++ b/src/future/oauth/PhutilOAuth1Future.php @@ -225,11 +225,12 @@ final class PhutilOAuth1Future extends FutureProxy { private function signString($string) { $consumer_secret = null; + $key = ''; if ($this->consumerSecret) { $consumer_secret = $this->consumerSecret->openEnvelope(); + $key .= urlencode($consumer_secret).'&'; } - $key = urlencode($consumer_secret).'&'; if ($this->tokenSecret !== null) { $key .= urlencode($this->tokenSecret); }