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
F3314315: D25855.1743228313.diff
Fri, Mar 28, 06:05
F3301311: D25855.1743052929.diff
Wed, Mar 26, 05:22
F3300385: D25855.1743038371.diff
Wed, Mar 26, 01:19
F3298170: D25855.1742998110.diff
Tue, Mar 25, 14:08
F3294783: D25855.1742943449.diff
Mon, Mar 24, 22:57
F3292447: D25855.1742893667.diff
Mon, Mar 24, 09:07
F3291972: D25855.1742885369.diff
Mon, Mar 24, 06:49
F3285701: D25855.1742807294.diff
Sun, Mar 23, 09:08

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.