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
F4030693: D25855.1746695221.diff
Wed, May 7, 09:07
F4011846: D25855.1746626764.diff
Tue, May 6, 14:06
F3904777: D25855.1746303929.diff
Fri, May 2, 20:25
F3734205: D25855.1745757307.diff
Sat, Apr 26, 12:35
F3702002: D25855.1745613137.diff
Thu, Apr 24, 20:32
F3682025: D25855.1745567342.diff
Thu, Apr 24, 07:49
F3681824: D25855.1745561383.diff
Thu, Apr 24, 06:09
F3673901: D25855.1745481992.diff
Wed, Apr 23, 08:06

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.Jan 10 2025, 10:51
This revision was automatically updated to reflect the committed changes.