Page MenuHomePhorge

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

Authored by aklapper on Aug 1 2023, 17:09.
Referenced Files
Unknown Object (File)
Thu, Sep 21, 06:53
Unknown Object (File)
Thu, Sep 14, 07:17
Unknown Object (File)
Sat, Sep 9, 21:14
Unknown Object (File)
Sat, Sep 2, 03:58
Unknown Object (File)
Tue, Aug 29, 14:54
Unknown Object (File)
Aug 22 2023, 03:26
Unknown Object (File)
Aug 21 2023, 11:59
Unknown Object (File)
Aug 21 2023, 07:16



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