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
F3823784: D25287.1746024433.diff
Tue, Apr 29, 14:47
F3810268: D25287.1745998343.diff
Tue, Apr 29, 07:32
F3806371: D25287.1745994578.diff
Tue, Apr 29, 06:29
F3800967: D25287.1745938001.diff
Mon, Apr 28, 14:46
F3605331: D25287.1745263716.diff
Sun, Apr 20, 19:28
F3554770: D25287.1744990690.diff
Thu, Apr 17, 15:38
F3553420: D25287.1744932817.diff
Wed, Apr 16, 23:33
F3372615: D25287.1744250570.diff
Wed, Apr 9, 02:02

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