Page MenuHomePhorge

Fix PHP 8.1 PhabricatorEditorURIEngine::newForViewer() trim(NULL) error
ClosedPublic

Authored by Sten on Jul 3 2023, 16:43.

Details

Summary

Under PHP 8.1, PhabricatorEditorURIEngine::newForViewer() is throwing a trim(NULL) error when trying to view a diff.
This is because it tries to apply string operations to a user setting which will be null by default.

Fixes T15518

Test Plan

Unit test added -

arc unit

Or just view a diff. Eg:
https://my.phorge.site/D1234

Diff Detail

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

Event Timeline

Sten requested review of this revision.Jul 3 2023, 16:43
src/infrastructure/editor/PhabricatorEditorURIEngine.php
19

Since we are not interested in knowing the length of the string. Also note that trim() always return a string, and never NULL.

19

Premising that your addition of $pattern === null is perfectly OK ✅

Thanks :) Soft +1 to wait for other thoughts. The test plan works for me.

Personally I will hard+1 if we get rid of that strlen() since we have that possibility here, and it's not such a frequent possibility.

Nice - complete removal of that strlen as suggested.

Sten marked an inline comment as done.Jul 5 2023, 13:44
This revision is now accepted and ready to land.Jul 17 2023, 07:16