Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exceptions trying to browse Diffusion repository history
ClosedPublic

Authored by aklapper on Jun 12 2023, 00:34.
Tags
None
Referenced Files
F2193963: D25287.1716036873.diff
Fri, May 17, 12:54
Unknown Object (File)
Sun, May 12, 23:55
Unknown Object (File)
Sun, May 12, 23:55
Unknown Object (File)
Sun, May 12, 12:27
Unknown Object (File)
Fri, May 10, 13:20
Unknown Object (File)
Wed, May 8, 14:20
Unknown Object (File)
Wed, May 8, 11:23
Unknown Object (File)
Wed, May 8, 11:23

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=97e163187418), phorge(head=diffusionBrowseCode, ref.master=108cbcd09bd3, ref.diffusionBrowseCode=015ffef14b0c)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php:50]
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=97e163187418), phorge(head=diffusionBrowseCode, ref.master=108cbcd09bd3, ref.diffusionBrowseCode=015ffef14b0c)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php:50]

Closes T15463

Test Plan

After applying these two changes, get next expected exceptions about RuntimeException: file_exists(): Passing null to parameter #1 ($filename) of type string is deprecated and CommandException: Command failed with error #128! fatal: detected dubious ownership in repository at '/var/repo/1', but no RuntimeException about strlen() anymore.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable