HomePhorge

Fix PHP 8.1 "preg_match(null)" exception which blocks rendering the "Browse…

Description

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

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.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15422

Differential Revision: https://we.phorge.it/D25248

Details

Provenance
Andre KlapperAuthored on May 31 2023, 12:38 AM
themackabuPushed on Mar 25 2025, 8:07 PM
Parents
rPe11c5486c92b: Fix typo in PhortuneMerchant.php
Branches
Unknown
Tags
Unknown

Event Timeline