1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

PHP 8.1 "strlen(null)" exception on SVN History page after changing "Import Only"

Summary:
`strlen()` was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts `phutil_nonempty_string()` as a replacement.

Note: this may highlight other absurd input values that might be worth correcting
instead of just ignoring. If phutil_nonempty_string() throws an exception in your
instance, report it to Phorge to evaluate and fix that specific corner case.

```
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=cb938d869c3f)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/repository/xaction/PhabricatorRepositorySVNSubpathTransaction.php:25]
```

Closes T15445

Test Plan: After applying this change, and after setting some "Import Only" value for a new Subversion repository, the page `/diffusion/1/manage/history/` renders showing `R1` being Inactive and `user set the repository "Import Only" path to main`.

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15445

Differential Revision: https://we.phorge.it/D25277
This commit is contained in:
Andre Klapper 2023-06-08 14:53:12 +02:00
parent b09471d557
commit 7af82abcb9

View file

@ -17,12 +17,12 @@ final class PhabricatorRepositorySVNSubpathTransaction
$old = $this->getOldValue(); $old = $this->getOldValue();
$new = $this->getNewValue(); $new = $this->getNewValue();
if (!strlen($new)) { if ($new === null || !strlen($new)) {
return pht( return pht(
'%s removed %s as the "Import Only" path.', '%s removed %s as the "Import Only" path.',
$this->renderAuthor(), $this->renderAuthor(),
$this->renderOldValue()); $this->renderOldValue());
} else if (!strlen($old)) { } else if ($old === null || !$old) {
return pht( return pht(
'%s set the repository "Import Only" path to %s.', '%s set the repository "Import Only" path to %s.',
$this->renderAuthor(), $this->renderAuthor(),