1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-24 15:52:40 +01:00

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
This commit is contained in:
Andre Klapper 2024-08-26 23:40:05 +02:00
parent ead6759082
commit 0358ff7ee3

View file

@ -225,11 +225,12 @@ final class PhutilOAuth1Future extends FutureProxy {
private function signString($string) { private function signString($string) {
$consumer_secret = null; $consumer_secret = null;
$key = '';
if ($this->consumerSecret) { if ($this->consumerSecret) {
$consumer_secret = $this->consumerSecret->openEnvelope(); $consumer_secret = $this->consumerSecret->openEnvelope();
$key .= urlencode($consumer_secret).'&';
} }
$key = urlencode($consumer_secret).'&';
if ($this->tokenSecret !== null) { if ($this->tokenSecret !== null) {
$key .= urlencode($this->tokenSecret); $key .= urlencode($this->tokenSecret);
} }