@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+2 -2
+2 -2
src/applications/repository/xaction/PhabricatorRepositoryStagingURITransaction.php
··· 17 17 $old = $this->getOldValue(); 18 18 $new = $this->getNewValue(); 19 19 20 - if (!strlen($old)) { 20 + if ($old === null || !strlen($old)) { 21 21 return pht( 22 22 '%s set %s as the staging area for this repository.', 23 23 $this->renderAuthor(), 24 24 $this->renderNewValue()); 25 - } else if (!strlen($new)) { 25 + } else if ($new === null || !strlen($new)) { 26 26 return pht( 27 27 '%s removed %s as the staging area for this repository.', 28 28 $this->renderAuthor(),