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)
Sun, May 19, 12:07
Unknown Object (File)
Sat, May 18, 07:24
Unknown Object (File)
Thu, May 16, 16:10
Unknown Object (File)
Wed, May 15, 17:25
Unknown Object (File)
Wed, May 15, 02:50
Unknown Object (File)
Tue, May 14, 19:24
Unknown Object (File)
Tue, May 14, 06:07
Unknown Object (File)
Tue, May 14, 00:25

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.