Page MenuHomePhorge

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

Authored by aklapper on Jun 4 2023, 09:51.
Tags
None
Referenced Files
F3827830: D25277.1746040368.diff
Tue, Apr 29, 19:12
F3792918: D25277.1745928207.diff
Mon, Apr 28, 12:03
F3720402: D25277.1745712819.diff
Sat, Apr 26, 00:13
F3665283: D25277.1745464724.diff
Wed, Apr 23, 03:18
F3604631: D25277.1745217071.diff
Sun, Apr 20, 06:31
F3526569: D25277.1744829902.diff
Tue, Apr 15, 18:58
F3485500: D25277.1744775061.diff
Tue, Apr 15, 03:44
F3390733: D25277.1744471018.diff
Fri, Apr 11, 15:16

Details

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.

Diff Detail

Repository
rP Phorge
Branch
SvnRepoSubpath (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 512
Build 512: arc lint + arc unit

Event Timeline

aklapper requested review of this revision.Jun 4 2023, 09:51
speck added inline comments.
src/applications/repository/xaction/PhabricatorRepositorySVNSubpathTransaction.php
20–25

Could you update both of these - I think $new might also be nullable?

This revision is now accepted and ready to land.Jun 8 2023, 00:27

Check for === null instead of using phutil_nonempty_string; check both $old and $new