Page MenuHomePhorge

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

Authored by aklapper on May 11 2024, 20:51.

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