@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

Fix PHP 8.1 "strlen(null)" exceptions creating an OAuth provider

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: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php:163]
```

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php:178]
```

```
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/auth/provider/PhabricatorOAuthAuthProvider.php:147]
```

Closes T15912

Test Plan: As an admin, create an OAuth provider (such as using Bitbucket) and check the error logs or Dark Console.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15912

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

+3 -3
+2 -2
src/applications/auth/provider/PhabricatorOAuth1AuthProvider.php
··· 160 160 161 161 switch ($key) { 162 162 case self::PROPERTY_CONSUMER_KEY: 163 - if (strlen($old)) { 163 + if (phutil_nonempty_string($old)) { 164 164 return pht( 165 165 '%s updated the OAuth consumer key for this provider from '. 166 166 '"%s" to "%s".', ··· 175 175 $new); 176 176 } 177 177 case self::PROPERTY_CONSUMER_SECRET: 178 - if (strlen($old)) { 178 + if (phutil_nonempty_string($old)) { 179 179 return pht( 180 180 '%s updated the OAuth consumer secret for this provider.', 181 181 $xaction->renderHandleLink($author_phid));
+1 -1
src/applications/auth/provider/PhabricatorOAuthAuthProvider.php
··· 144 144 145 145 switch ($key) { 146 146 case self::PROPERTY_NOTE: 147 - if (strlen($old)) { 147 + if (phutil_nonempty_string($old)) { 148 148 return pht( 149 149 '%s updated the OAuth application notes for this provider.', 150 150 $xaction->renderHandleLink($author_phid));