From 4e50717e12722bc68b63fc713683392c69f56196 Mon Sep 17 00:00:00 2001 From: hannes Date: Sat, 23 Jan 2016 15:01:27 +0000 Subject: [PATCH] output error if json_encode fails --- lib/apiaction.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/apiaction.php b/lib/apiaction.php index 8420bfb51e..24f42e4a41 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -771,9 +771,15 @@ class ApiAction extends Action function showJsonObjects($objects) { - print(json_encode($objects)); + $json_objects = json_encode($objects); + if($json_objects === false) { + $this->clientError(_('JSON encoding failed. Error: ').json_last_error_msg()); + } else { + print $json_objects; + } } + function showSingleXmlStatus($notice) { $this->initDocument('xml'); @@ -1558,4 +1564,4 @@ class ApiAction extends Action return $uri; } -} +} \ No newline at end of file -- 2.39.5