Skip to content

Commit

Permalink
PHP 8.1 "strlen(null)" exception on SVN History page after changing "…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
aklapper committed Jun 8, 2023
1 parent b09471d commit 7af82ab
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();

if (!strlen($new)) {
if ($new === null || !strlen($new)) {
return pht(
'%s removed %s as the "Import Only" path.',
$this->renderAuthor(),
$this->renderOldValue());
} else if (!strlen($old)) {
} else if ($old === null || !$old) {
return pht(
'%s set the repository "Import Only" path to %s.',
$this->renderAuthor(),
Expand Down

0 comments on commit 7af82ab

Please sign in to comment.