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
F3646769: D25855.1745395167.diff
Tue, Apr 22, 07:59
F3577076: D25855.1745079310.diff
Fri, Apr 18, 16:15
F3483354: D25855.1744771036.diff
Tue, Apr 15, 02:37
F3458893: D25855.1744736291.diff
Mon, Apr 14, 16:58
F3406829: D25855.1744586248.diff
Sat, Apr 12, 23:17
F3391342: D25855.1744478247.diff
Fri, Apr 11, 17:17
F3388085: D25855.1744444317.diff
Fri, Apr 11, 07:51
F3388084: D25855.1744444310.diff
Fri, Apr 11, 07:51

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
Branch
jsonParserNonIterable (branched from master)
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 1663
Build 1663: arc lint + arc unit

Unit TestsFailed

TimeTest
798 msArcanistBundleTestCase::testGitRepository
EXCEPTION (Exception): Expected patch and actual patch for 5dec8bf28557f078d1987c4e8cfb53d08310f522 differ. Wrote actual patch to '/var/www/html/phorge/arcanist/src/parser/__tests__/patches//5dec8bf28557f078d1987c4e8cfb53d08310f522.gitpatch.real'. #0 /var/www/html/phorge/arcanist/src/parser/__tests__/ArcanistBundleTestCase.php(87): ArcanistBundleTestCase->runGitRepositoryTests(Object(PhutilDirectoryFixture)) #1 /var/www/html/phorge/arcanist/src/unit/engine/phutil/PhutilTestCase.php(639): ArcanistBundleTestCase->testGitRepository()
48 msArcanistBaseCommitParserTestCase::testBasics
2 assertion(s) passed.
57 msArcanistBaseCommitParserTestCase::testHalt
1 assertion(s) passed.
46 msArcanistBaseCommitParserTestCase::testJump
1 assertion(s) passed.
52 msArcanistBaseCommitParserTestCase::testJumpReturn
1 assertion(s) passed.
View Full Test Results (1 Failed · 74 Passed)

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.