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
F2980263: D25273.1739888453.diff
Mon, Feb 17, 14:20
F2940163: D25273.1738041314.diff
Mon, Jan 27, 05:15
F2940162: D25273.1738041313.diff
Mon, Jan 27, 05:15
F2940077: D25273.1738038665.diff
Mon, Jan 27, 04:31
F2934636: D25273.1737795630.diff
Fri, Jan 24, 09:00
F2932804: D25273.1737743916.diff
Thu, Jan 23, 18:38
F2931840: D25273.1737728023.diff
Thu, Jan 23, 14:13
F2901538: D25273.1737281576.diff
Jan 18 2025, 10:12

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