@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

Conduit: Fix PHP 8.1 "strlen(null)" exceptions in feed.query

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/feed/conduit/FeedQueryConduitAPIMethod.php:79]
ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/feed/conduit/FeedQueryConduitAPIMethod.php:84]
```

Closes T16419

Test Plan:
* PHP 8.1+
* Go to http://phorge.localhost/conduit/method/feed.query/
* Press the "Call Method" button
* Go to http://phorge.localhost/conduit/method/feed.query/ and enter values in the `before` and `after` fields
* Press the "Call Method" button

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T16419

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

+2 -2
+2 -2
src/applications/feed/conduit/FeedQueryConduitAPIMethod.php
··· 76 76 ->setPageSize($limit); 77 77 78 78 $after = $request->getValue('after'); 79 - if (strlen($after)) { 79 + if (phutil_nonempty_scalar($after)) { 80 80 $pager->setAfterID($after); 81 81 } 82 82 83 83 $before = $request->getValue('before'); 84 - if (strlen($before)) { 84 + if (phutil_nonempty_scalar($before)) { 85 85 $pager->setBeforeID($before); 86 86 } 87 87