Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception opening a File overlay (Lightbox comment frame)
ClosedPublic

Authored by aklapper on Jun 25 2023, 10:32.

Details

Summary

The error was caused by the overlay lightbox, since it gives the possibility to share a comment on any file
in any general Remarkup text, but that comment textarea is indeed empty as default.

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=T15498, ref.master=a25af8ccef69, ref.T15498=a25af8ccef69)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/files/controller/PhabricatorFileLightboxController.php:23]

Closes T15498

Test Plan

Visit a blog post with a file/image dropped in the content and click on the thumbnail. No error overlay dialog is displayed anymore.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

valerio.bozzolan retitled this revision from Fix PHP 8.1 "strlen(null)" exception opening image details in a Phame blog post to Fix PHP 8.1 "strlen(null)" exception opening a File overlay (Lightbox comment frame).
valerio.bozzolan edited the summary of this revision. (Show Details)
valerio.bozzolan edited the test plan for this revision. (Show Details)

It took me a little while to understand the problem because I thought we were talking about the blog image, instead this problem probably affects any file in any description of any Task.

Tested locally, no nuclear implosions. Thanks!

This revision is now accepted and ready to land.Jul 5 2023, 12:46