diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/controllers/api/v2/file.php | 6 | ||||
-rw-r--r-- | application/helpers/filebin_helper.php | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/application/controllers/api/v2/file.php b/application/controllers/api/v2/file.php index 5dedcd508..c3a42388b 100644 --- a/application/controllers/api/v2/file.php +++ b/application/controllers/api/v2/file.php @@ -66,11 +66,7 @@ class file extends \controllers\api\api_controller { } } - foreach (array("items", "multipaste_items") as $key) { - if (empty($history[$key])) { - $history[$key] = (object) array(); - } - } + $history = ensure_json_keys_contain_objects($history, array("items", "multipaste_items")); return $history; } diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index 55fdf773d..c1a6f4f96 100644 --- a/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php @@ -383,4 +383,13 @@ function return_bytes($size_str) } } +function ensure_json_keys_contain_objects($data, $keys) { + foreach ($keys as $key) { + if (empty($data[$key])) { + $data[$key] = (object) array(); + } + } + return $data; +} + # vim: set noet: |