Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception setting Passphrase Credential

Authored by aklapper on Aug 1 2023, 17:09.
Referenced Files
F2310023: D25370.1721378563.diff
Thu, Jul 18, 08:42
Unknown Object (File)
Tue, Jul 16, 08:39
Unknown Object (File)
Tue, Jul 16, 04:20
Unknown Object (File)
Mon, Jul 15, 12:24
Unknown Object (File)
Tue, Jul 9, 06:59
Unknown Object (File)
Tue, Jul 9, 02:46
Unknown Object (File)
Sat, Jul 6, 18:35
Unknown Object (File)
Sat, Jul 6, 18:34



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=788098096e11), phorge(head=master, ref.master=840a7fab2bc8)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/src/applications/passphrase/view/PassphraseCredentialControl.php:53]

Closes T15580

Test Plan

Set URI for a Diffusion Repository, select URI and select "Set Credential". Page "Edit Repository URI" at /diffusion/123/uri/edit/456/ renders as expected in web browser.

Diff Detail

rP Phorge
Lint Not Applicable
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Aug 1 2023, 17:09
valerio.bozzolan added inline comments.

I wonder why in the original version they have not used just:

if (!$current_phid && ...) {

As far as I know, this would be the most reliable, readable and minimal check, without any PHP8.1 pitfall.

@avivey do you somehow agree?

I see no problem with consistency.

This revision is now accepted and ready to land.Aug 7 2023, 03:11