Page MenuHomePhorge

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

Authored by aklapper on Aug 1 2023, 17:09.
Tags
None
Referenced Files
F2324123: D25370.1721743853.diff
Mon, Jul 22, 14:10
F2324122: D25370.1721743853.diff
Mon, Jul 22, 14:10
F2324008: D25370.1721743399.diff
Mon, Jul 22, 14:03
Unknown Object (File)
Sun, Jul 21, 16:59
Unknown Object (File)
Fri, Jul 19, 13:24
Unknown Object (File)
Thu, Jul 18, 08:42
Unknown Object (File)
Tue, Jul 16, 08:39
Unknown Object (File)
Tue, Jul 16, 04:20

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=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

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

aklapper requested review of this revision.Aug 1 2023, 17:09
valerio.bozzolan added inline comments.
src/applications/passphrase/view/PassphraseCredentialControl.php
53

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