Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception creating a Paste without content in Conduit paste.create
ClosedPublic

Authored by aklapper on Aug 17 2023, 15:28.

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=df6c315ace5f), phorge(head=thisThis, ref.master=7cffe557ac24, ref.thisThis=529790613a86)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/paste/conduit/PasteCreateConduitAPIMethod.php:46]

Closes T15613

Test Plan

Create a paste in the deprecated API paste.create without content via Conduit. Shows error_code ERR-NO-PASTE as expected, and no exception.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I'm not able to trigger that part of the code.

I tried with:

cat /dev/null | arc paste --

Also tried with Conduit paste.edit and transactions = []

Also tried with Conduit paste.edit and transactions = [{"type": "text", "value": ""}]

But line 46 is never executed to me. Any better test plan suggested?

valerio.bozzolan retitled this revision from Fix PHP 8.1 "strlen(null)" exception creating a Paste without content in Conduit to Fix PHP 8.1 "strlen(null)" exception creating a Paste without content in Conduit paste.create.Aug 18 2023, 02:50
valerio.bozzolan edited the test plan for this revision. (Show Details)

OK I've found that this is about the legacy Conduit entry point for Paste.

Tested! It works also on my side! Thanks!

lgtm

This revision is now accepted and ready to land.Aug 18 2023, 02:59