Fix a notice when setting a picture description via API
authorMichael <heluecht@pirati.ca>
Fri, 2 Aug 2019 16:43:36 +0000 (16:43 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 2 Aug 2019 16:43:36 +0000 (16:43 +0000)
include/api.php

index 5665a7f..2c9ae9b 100644 (file)
@@ -343,11 +343,13 @@ function api_call(App $a)
                                                break;
                                        case "json":
                                                header("Content-Type: application/json");
-                                               $json = json_encode(end($return));
-                                               if (!empty($_GET['callback'])) {
-                                                       $json = $_GET['callback'] . "(" . $json . ")";
+                                               if (!empty($return)) {
+                                                       $json = json_encode(end($return));
+                                                       if (!empty($_GET['callback'])) {
+                                                               $json = $_GET['callback'] . "(" . $json . ")";
+                                                       }
+                                                       $return = $json;
                                                }
-                                               $return = $json;
                                                break;
                                        case "rss":
                                                header("Content-Type: application/rss+xml");