Page MenuHomePhorge

Fix PHP 8.1 "preg_split()(null)" exception registering account without Real Name
AbandonedPublic

Authored by aklapper on Jul 2 2023, 14:58.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 17:24
Unknown Object (File)
Sat, Apr 13, 22:45
Unknown Object (File)
Thu, Apr 4, 11:14
Unknown Object (File)
Thu, Apr 4, 11:14
Unknown Object (File)
Thu, Apr 4, 11:11
Unknown Object (File)
Thu, Apr 4, 11:09
Unknown Object (File)
Mon, Apr 1, 02:15
Unknown Object (File)
Mon, Apr 1, 02:14

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) preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=97e163187418), phorge(head=T15443, ref.master=8ffa6044626d, ref.T15443=8ffa6044626d)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/error/PhutilErrorHandler.php:261]
  #1 <#2> preg_split(string, NULL) called at [<phorge>/src/applications/auth/engine/PhabricatorAuthPasswordEngine.php:159]

Closes T15514

Test Plan

After applying the patch, /auth/register/ shows expected error "Real name is required." after attempting to register an account.

Diff Detail

Repository
rP Phorge
Branch
registerAccountEmailRequired (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 618
Build 618: arc lint + arc unit

Event Timeline

aklapper requested review of this revision.Jul 2 2023, 14:58

The assertion for Harbormaster Unit 10862 has failed. Does anyone know why?

The assertion for Harbormaster Unit 10862 has failed. Does anyone know why?

Because my tree was not clean though I told arc diff to ignore all other files. Guess I need to amend.

Hopefully fix unit test by running arc liberate locally first

valerio.bozzolan added a subscriber: avivey.

Thanks for this patch

Marking as request changes, since fortunately it seems that master is already fixed thanks to @avivey, just before the loop in the master :)

src/applications/auth/engine/PhabricatorAuthPasswordEngine.php
152

In the master, in line 153 here now there is a function that should already fix this thing

https://we.phorge.it/source/phorge/browse/master/src/applications/auth/engine/PhabricatorAuthPasswordEngine.php;d725ffaa7728bdbcd07870e9e8f4d244eb9dcf41$153

Interesting edit conflict, look at the dates :O

This revision now requires changes to proceed.Jul 3 2023, 07:15

Looks like a mid-air collision, heh :)