@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix PHP 8.1 "strlen(null)" exception in Client ID handling of PhabricatorOAuthServerTokenController

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.

```
strlen(): Passing null to parameter #1 ($string) of type string is deprecated
#0 PhabricatorOAuthServerTokenController::handleRequest(AphrontRequest) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:284]
```

See Q182

Test Plan: Read the code. `strlen` is used to get the length of an existing string and not to check for emptiness of a string. There is no string length comparison in the existing code.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D26034

+2 -1
+2 -1
src/applications/oauthserver/controller/PhabricatorOAuthServerTokenController.php
··· 23 23 24 24 $client_id_parameter = $request->getStr('client_id'); 25 25 $client_id_header = idx($_SERVER, 'PHP_AUTH_USER'); 26 - if (strlen($client_id_parameter) && strlen($client_id_header)) { 26 + if (phutil_nonempty_string($client_id_parameter) && 27 + phutil_nonempty_string($client_id_header)) { 27 28 if ($client_id_parameter !== $client_id_header) { 28 29 throw new Exception( 29 30 pht(