Page MenuHomePhorge

Fix PHP 8.1 "preg_match(null)" exception on "Create Revision" page in Differential when not entering data
ClosedPublic

Authored by aklapper on May 30 2023, 10:35.

Details

Summary

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

Thus add a phutil_nonempty_string() check if the $subject parameter is a non-empty string.

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_match(): Passing null to parameter #2 ($subject) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=18554ea76ceb), phorge(head=diffAttach, ref.master=e11c5486c92b, ref.diffAttach=e11c5486c92b)
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/error/PhutilErrorHandler.php:261]
  #1 <#2> preg_match(string, NULL, NULL) called at [<phorge>/src/applications/differential/editor/DifferentialTransactionEditor.php:221]

Closes T15431

Test Plan

After applying this change on top of D25262, going to /differential/diff/create/, creating a diff, and entering nothing on the "Create Revision" page on /differential/revision/attach/1/to/ correctly shows the errors "You must provide a test plan. Describe the actions you performed to verify the behavior of this change. Revisions must have a title." in web browser instead of an exception.

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

speck requested changes to this revision.Jun 8 2023, 00:36
speck added inline comments.
src/applications/differential/editor/DifferentialTransactionEditor.php
221–222

Please update this to be consistent with the change that lands for D25268#change-HsYn5r9Vm2Ju

This revision now requires changes to proceed.Jun 8 2023, 00:36
This revision is now accepted and ready to land.Jun 8 2023, 11:06