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
F2196665: D25370.1716209333.diff
Sun, May 19, 12:48
Unknown Object (File)
Fri, May 17, 00:08
Unknown Object (File)
Fri, May 10, 19:58
Unknown Object (File)
Sat, May 4, 14:18
Unknown Object (File)
Sat, May 4, 14:18
Unknown Object (File)
Sat, May 4, 13:22
Unknown Object (File)
Sat, May 4, 12:33
Unknown Object (File)
Sun, Apr 28, 12:29

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
Branch
CredentialStrlen (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 719
Build 719: arc lint + arc unit

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