Page MenuHomePhorge

JSON rendering: Avoid exception iterating on non-iterable objects
ClosedPublic

Authored by aklapper on Dec 11 2024, 20:14.
Tags
None
Referenced Files
F2916472: D25855.1737489595.diff
Mon, Jan 20, 19:59
F2915190: D25855.1737466077.diff
Mon, Jan 20, 13:27
F2905436: D25855.1737346049.diff
Sun, Jan 19, 04:07
F2904794: D25855.1737333202.diff
Sun, Jan 19, 00:33
F2898917: D25855.1737258365.diff
Sat, Jan 18, 03:46
F2887604: D25855.1737176439.diff
Fri, Jan 17, 05:00
F2874971: D25855.1736968255.diff
Tue, Jan 14, 19:10
F2874970: D25855.1736968255.diff
Tue, Jan 14, 19:10

Details

Summary

Check for is_iterable($object) (available since PHP 7.1) to avoid an exception calling foreach on $object in the rare case that the object is a custom Phorge class (PHUIBoxView, PhutilSafeHTML) and not an array. cf https://we.phorge.it/rARC7570dd0da119627ff83bc6db3be06b51eb5b366b for a similar patch to handle PHP stdClass objects.

See downstream https://phabricator.wikimedia.org/T373316.

Test Plan

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I see a red light in a unit test but it works on me after the patch src/parser/__tests__/ArcanistBundleTestCase.php - any comment on that? Anyway sgtm since it needs the foreach() stuff later.

sgtm

This revision is now accepted and ready to land.Dec 12 2024, 10:14

git clean -fx to hopefully avoid test failure

This revision was landed with ongoing or failed builds.Fri, Jan 10, 10:51
This revision was automatically updated to reflect the committed changes.