From 614e6756ee8b54b0611613f2fb0d1613384ab860 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Mon, 15 Dec 2025 12:31:03 +0100 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception when using Diffusion 'Compare' Summary: The method 'getSymbolicCommit()' can return null, and that value is not passed to strlen() anymore. Closes T16297 Test Plan: Visit the Diffusion page 'Compare' page without inputs, no warnings anymore from Dark console: http://phorge.localhost/diffusion/1/compare/ Visit all the Diffusion page 'Compare' page of all your branches, they still work: http://phorge.localhost/diffusion/1/branches/master/ (e.g. tested with branches 'master', 'devops', 'weblate', 'crashtest') Compare two real branches like 'master' and 'test' or whatever, from this page, and it still works: http://phorge.localhost/diffusion/1/compare/ Invert the branches. It still works. Reviewers: O1 Blessed Committers, aklapper Reviewed By: O1 Blessed Committers, aklapper Subscribers: aklapper, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T16297 Differential Revision: https://we.phorge.it/D26422 --- .../diffusion/controller/DiffusionCompareController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/applications/diffusion/controller/DiffusionCompareController.php b/src/applications/diffusion/controller/DiffusionCompareController.php index 26d888dfb2..5e18c1db88 100644 --- a/src/applications/diffusion/controller/DiffusionCompareController.php +++ b/src/applications/diffusion/controller/DiffusionCompareController.php @@ -27,14 +27,14 @@ final class DiffusionCompareController extends DiffusionController { ->addCancelButton($this->getApplicationURI(), pht('Okay')); } - $head_ref = $request->getStr('head'); - $against_ref = $request->getStr('against'); + $head_ref = $request->getStr('head', ''); + $against_ref = $request->getStr('against', ''); $must_prompt = false; if (!$request->isFormPost()) { if (!strlen($head_ref)) { $head_ref = $drequest->getSymbolicCommit(); - if (!strlen($head_ref)) { + if (!phutil_nonempty_string($head_ref)) { $head_ref = $drequest->getBranch(); } } -- 2.51.2