Page MenuHomePhorge

Fix PHP 8.1 "preg_replace(null)" exception in PhabricatorEditorURIEngine.php
Needs ReviewPublic

Authored by aklapper on Sat, May 11, 20:51.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 30, 22:19
Unknown Object (File)
Wed, May 22, 13:42
Unknown Object (File)
Wed, May 22, 13:31
Unknown Object (File)
Wed, May 22, 13:23
Unknown Object (File)
Mon, May 20, 21:04
Unknown Object (File)
Mon, May 20, 17:16
Unknown Object (File)
Sun, May 19, 12:07
Unknown Object (File)
Sat, May 18, 07:24

Details

Summary

Passing null to preg_replace() is deprecated behavior since PHP 8.1.
Thus only call preg_replace() when $token is non-empty.

ERROR 8192: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated at [<phorge>/src/infrastructure/editor/PhabricatorEditorURIEngine.php:283]

Closes T15824

Test Plan

Unclear.

Diff Detail

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

Event Timeline

How can we end up with null here?

Uhm, seems I was somehow off by one line. I thought that this comes from escapeToken($repository->getCallsign()) being optional nowadays but seems to be triggered by escapeToken($repository->getRepositorySlug()) instead which indeed would be surprising. This might be a patch to abandon because might hide an underlying issue.