Page MenuHomePhorge

Fix passing null to trim() error in DiffusionBrowseTableView render()
ClosedPublic

Authored by Sten on Jul 4 2023, 15:13.

Details

Summary

When viewing the top level of a diffusion repository, $request->getPath() returns null, which then causes trim() to throw an error.

Fix is to update DiffusionRequest getPath() such that it returns '' instead of null, thus fixing it's return type.

Fixes T15522

Test Plan

Diff Detail

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

Event Timeline

Sten requested review of this revision.Jul 4 2023, 15:13

Remove earlier changes to DiffusionBrowseTableView

src/applications/diffusion/request/DiffusionRequest.php
12

Note that, if we are sure that the default should never be NULL, we can just assume this default ↑

But take this tip with small tweezers.

src/applications/diffusion/request/DiffusionRequest.php
12

Great minds think alike - this was the first thing I tried, and we still got the error.
Seems that $path is being set to null elsewhere.

src/applications/diffusion/request/DiffusionRequest.php
12

.__.

257

Maybe you can like this function: coalesce()

Example use:

return coalesce($this->path, '');

Soft +1 but we need some other opinions here

coalesce - I like that. It's going to see some use!

Sten marked an inline comment as done.Jul 5 2023, 15:45
This revision is now accepted and ready to land.Jul 17 2023, 06:02