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.

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
arcpatch-D25277
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 520
Build 520: 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