mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Fix PHP 8.1 "strlen(null)" exceptions trying to View Branches of a Diffusion repository
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. ``` EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261] arcanist(head=master, ref.master=e4fd31ec024e), phorge(head=D25241, ref.master=b1edfea09bad, ref.D25241=b1edfea09bad) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/diffusion/controller/DiffusionBranchTableController.php:29] ``` ``` EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261] arcanist(head=master, ref.master=e4fd31ec024e), phorge(head=D25241, ref.master=b1edfea09bad, ref.D25241=b1edfea09bad) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php:33] ``` Closes T15414 Test Plan: Applied these two changes and at least got to `(FilesystemException) Filesystem path "/var/repo/1/" does not exist.` as an error message, instead of being stuck at `(RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated`. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15414 Differential Revision: https://we.phorge.it/D25241
This commit is contained in:
parent
cbc0e66154
commit
0cbcb110b0
2 changed files with 2 additions and 2 deletions
|
@ -30,7 +30,7 @@ final class DiffusionBranchQueryConduitAPIMethod
|
|||
$repository = $drequest->getRepository();
|
||||
|
||||
$contains = $request->getValue('contains');
|
||||
if (strlen($contains)) {
|
||||
if (phutil_nonempty_string($contains)) {
|
||||
|
||||
// See PHI958 (and, earlier, PHI720). If "patterns" are provided, pass
|
||||
// them to "git branch ..." to let callers test for reachability from
|
||||
|
|
|
@ -26,7 +26,7 @@ final class DiffusionBranchTableController extends DiffusionController {
|
|||
);
|
||||
|
||||
$contains = $drequest->getSymbolicCommit();
|
||||
if (strlen($contains)) {
|
||||
if (phutil_nonempty_string($contains)) {
|
||||
$params['contains'] = $contains;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue