mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-01-27 23:18:19 +01:00
JSON rendering: Avoid exception iterating on non-iterable objects
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: * Unclear to reproduce the actual issue, likely something Feed related. * Open an existing JSON Paste at http://phorge.localhost/P1 and see that it still renders. * Open an existing JSON File at http://phorge.localhost/F1 and see that it still renders. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25855
This commit is contained in:
parent
abda702083
commit
f0176263a7
1 changed files with 1 additions and 1 deletions
|
@ -51,7 +51,7 @@ final class PhutilJSON extends Phobject {
|
|||
$object = (array)$object;
|
||||
}
|
||||
|
||||
if (empty($object)) {
|
||||
if (empty($object) || !is_iterable($object)) {
|
||||
return '{}';
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue