HomePhorge

Fix PHP 8.1 "strlen(null)" exceptions block creating a diff in Differential web…

Description

Fix PHP 8.1 "strlen(null)" exceptions block creating a diff in Differential web interface

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=18554ea76ceb), phorge(head=diffDiff, ref.master=e11c5486c92b, ref.diffDiff=e11c5486c92b)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/infrastructure/diff/view/PHUIDiffTableOfContentsItemView.php:160]

Closes T15430

Test Plan:
After applying these two changes, going to /differential/diff/create/, pasting the content of a diff file into the "Raw Diff" field, and selecting the "Create Diff" button, /differential/diff/1/ rendered correctly in web browser.

Also, install xdebug and try again with coverage mode enabled in your php.ini of your PHP cli.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15430

Differential Revision: https://we.phorge.it/D25262

Details

Provenance
Andre KlapperAuthored on Jun 2 2023, 11:39 AM
themackabuPushed on Mar 25 2025, 8:07 PM
Parents
rP0cbcb110b03b: Fix PHP 8.1 "strlen(null)" exceptions trying to View Branches of a Diffusion…
Branches
Loading...
Tags
Loading...

Event Timeline