Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception setting a Diffusion repo URI when diffusion.ssh-host is null
ClosedPublic

Authored by aklapper on Jun 3 2023, 12:22.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 10, 18:18
Unknown Object (File)
Fri, May 10, 18:18
Unknown Object (File)
Fri, May 10, 18:18
Unknown Object (File)
Wed, May 8, 11:23
Unknown Object (File)
Wed, May 8, 11:23
Unknown Object (File)
Wed, May 8, 10:11
Unknown Object (File)
Wed, May 8, 09:27
Unknown Object (File)
Sat, Apr 27, 16:31

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=diffusionCreateRepoURI, ref.master=d8d65f3f87ed, ref.diffusionCreateRepoURI=d8d65f3f87ed)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/repository/storage/PhabricatorRepositoryURI.php:755]

Closes T15444

Test Plan

After applying this change and setting a repo URI following the steps in T15444, the page "R10: URI 58" on /diffusion/10/uri/view/58/ is correctly rendered without an exception.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable