From 849e18ccbbea99643f51a8ee300446a42f61b418 Mon Sep 17 00:00:00 2001 From: Steve Campbell Date: Wed, 5 Jul 2023 15:33:02 +0100 Subject: [PATCH] Fix PhabricatorRepository generateURI PHP 8.1 strlen(null) errors Summary: When viewing a repository in Diffusion, clicking on a folder (eg https://my.phorge.site/source/myrepo/browse/master/myfolder/) will generate multiple strlen(null) exceptions under PHP 8.1 Fix is to replace all the strlen() calls with phutil_nonempty_string() Fixes T15532 Test Plan: View a folder in a repo in Diffusion. Eg https://my.phorge.site/source/myrepo/browse/master/myfolder/ Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15532 Differential Revision: https://we.phorge.it/D25336 --- .../repository/storage/PhabricatorRepository.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php index eb57b31b57..4a1c923622 100644 --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -779,15 +779,15 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO break; case 'compare': $uri = $this->getPathURI("/{$action}/"); - if (strlen($head)) { + if (phutil_nonempty_scalar($head)) { $query['head'] = $head; - } else if (strlen($raw_commit)) { + } else if (phutil_nonempty_scalar($raw_commit)) { $query['commit'] = $raw_commit; - } else if (strlen($raw_branch)) { + } else if (phutil_nonempty_scalar($raw_branch)) { $query['head'] = $raw_branch; } - if (strlen($against)) { + if (phutil_nonempty_scalar($against)) { $query['against'] = $against; } break;