1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

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 [<arcanist>/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 [<phorge>/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
This commit is contained in:
Andre Klapper 2023-06-10 18:33:58 +02:00
parent bab9970740
commit 76ef9db8a5

View file

@ -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(),