Page MenuHomePhorge

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

Authored by aklapper on May 11 2024, 20:51.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jul 25, 13:17
Unknown Object (File)
Thu, Jul 25, 01:18
Unknown Object (File)
Mon, Jul 22, 15:18
Unknown Object (File)
Mon, Jul 22, 14:09
Unknown Object (File)
Mon, Jul 22, 14:02
Unknown Object (File)
Sun, Jul 21, 17:00
Unknown Object (File)
Fri, Jul 12, 07:12
Unknown Object (File)
Wed, Jul 10, 05:02

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.

revi confirmed this is called by getRepositorySlug() so abandoning this patch as hiding the underlying issue (no repository slug defined?) is not the right approach