Page MenuHomePhorge

Fix PHP 8.1 "preg_match(null)" exception which blocks rendering the "Browse Herald Rules" dialog
ClosedPublic

Authored by aklapper on May 26 2023, 21:34.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 29, 09:38
Unknown Object (File)
Mon, Apr 29, 09:30
Unknown Object (File)
Mon, Apr 29, 07:57
Unknown Object (File)
Mon, Apr 29, 07:54
Unknown Object (File)
Mon, Apr 29, 06:34
Unknown Object (File)
Sat, Apr 27, 12:38
Unknown Object (File)
Mon, Apr 22, 06:32
Unknown Object (File)
Mon, Apr 22, 01:12

Details

Summary

preg_match() does not accept passing null as the $subject string parameter in PHP 8.1.

Thus first check that $subject !== null.

EXCEPTION: (RuntimeException) preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=0e32dbc1ac8f), phorge(head=diffusionRepoPage, ref.master=5405134fa5db, ref.diffusionRepoPage=dbe5e3a68c41)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/error/PhutilErrorHandler.php:261]
  #1 <#2> preg_match(string, NULL) called at [<phorge>/src/applications/herald/typeahead/HeraldRuleDatasource.php:25]

Closes T15422

Test Plan

Applied this change; afterwards on the "Diffusion 🡒 Push Logs 🡒 Advanced Search" page at /diffusion/pushlog/?repositories=PHID-REPO-someRepositoryString, clicking the search icon for the "Blocked By" field correctly renders.the "Browse Herald Rules" overlay dialog, listing available Herald rules.

Diff Detail

Repository
rP Phorge
Branch
arcpatch-D25248
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 494
Build 494: arc lint + arc unit

Event Timeline

Shorten 87 char line to pass linter

Thanks again :) Soft +1

Also here our phutil is maybe overkill since an emtpy string is a don't care. So a strict check anti-null is probably safer:

$raw_query !== null

Hard +1 in that case from me. Thanks again

Edted: also updating a bit the summary.

Use $raw_query !== null as requested

Thanks for your minimal change

(tip: no need to use brackets, but that is up to readability preferences I guess)

sgtm

This revision is now accepted and ready to land.May 31 2023, 07:09
aklapper retitled this revision from Fix PHP 8.1 "strlen(null)" exception which blocks rendering the "Browse Herald Rules" dialog to Fix PHP 8.1 "preg_match(null)" exception which blocks rendering the "Browse Herald Rules" dialog.May 31 2023, 07:37
aklapper edited the summary of this revision. (Show Details)