From 76ef9db8a5ed652b5d74f6a85031e1292a897837 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Sat, 10 Jun 2023 18:33:58 +0200 Subject: [PATCH] Fix PHP 8.1 "strlen(null)" exception about Staging URI on Diffusion repo History page Summary: `strlen()` was used in Phabricator to check if a generic value is a non-empty string. Passing null to strlen() is deprecated since PHP 8.1. Thus first check that the string is not null. ``` EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/src/error/PhutilErrorHandler.php:261] arcanist(head=master, ref.master=b325304b6e52), phorge(head=master, ref.master=83edbffd521d) #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/applications/repository/xaction/PhabricatorRepositoryStagingURITransaction.php:20] ``` This is quite similar to D25277. Closes T15458 Test Plan: After applying this change, editing the Staging URI by saving its already empty value, and going to the repo History page, the page `/diffusion/1/manage/history/` renders without an exception, showing `R1` being Inactive and `user set as the staging area for this repository.` [sic!] Reviewers: O1 Blessed Committers, speck Reviewed By: O1 Blessed Committers, speck Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15458 Differential Revision: https://we.phorge.it/D25282 --- .../xaction/PhabricatorRepositoryStagingURITransaction.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/applications/repository/xaction/PhabricatorRepositoryStagingURITransaction.php b/src/applications/repository/xaction/PhabricatorRepositoryStagingURITransaction.php index 4297d5e244..ed50f65e4e 100644 --- a/src/applications/repository/xaction/PhabricatorRepositoryStagingURITransaction.php +++ b/src/applications/repository/xaction/PhabricatorRepositoryStagingURITransaction.php @@ -17,12 +17,12 @@ final class PhabricatorRepositoryStagingURITransaction $old = $this->getOldValue(); $new = $this->getNewValue(); - if (!strlen($old)) { + if ($old === null || !strlen($old)) { return pht( '%s set %s as the staging area for this repository.', $this->renderAuthor(), $this->renderNewValue()); - } else if (!strlen($new)) { + } else if ($new === null || !strlen($new)) { return pht( '%s removed %s as the staging area for this repository.', $this->renderAuthor(),