Replace json_encode + exit by System::jsonExit in mod/item

This commit is contained in:
Hypolite Petovan 2020-01-29 22:31:13 -05:00
parent 2c2b649015
commit 694d93ded9

View File

@ -54,8 +54,7 @@ function item_post(App $a) {
$arr_drop = explode(',', $_REQUEST['dropitems']); $arr_drop = explode(',', $_REQUEST['dropitems']);
drop_items($arr_drop); drop_items($arr_drop);
$json = ['success' => 1]; $json = ['success' => 1];
echo json_encode($json); System::jsonExit($json);
exit();
} }
Hook::callAll('post_local_start', $_REQUEST); Hook::callAll('post_local_start', $_REQUEST);
@ -319,7 +318,7 @@ function item_post(App $a) {
if (!strlen($body)) { if (!strlen($body)) {
if ($preview) { if ($preview) {
exit(); System::jsonExit(['preview' => '']);
} }
info(DI::l10n()->t('Empty post discarded.') . EOL); info(DI::l10n()->t('Empty post discarded.') . EOL);
if (!empty($_REQUEST['return'])) { if (!empty($_REQUEST['return'])) {
@ -665,8 +664,8 @@ function item_post(App $a) {
$o = conversation($a, [array_merge($contact_record, $datarray)], new Pager(DI::args()->getQueryString()), 'search', false, true); $o = conversation($a, [array_merge($contact_record, $datarray)], new Pager(DI::args()->getQueryString()), 'search', false, true);
Logger::log('preview: ' . $o); Logger::log('preview: ' . $o);
echo json_encode(['preview' => $o]);
exit(); System::jsonExit(['preview' => $o]);
} }
Hook::callAll('post_local',$datarray); Hook::callAll('post_local',$datarray);
@ -682,8 +681,7 @@ function item_post(App $a) {
$json['reload'] = DI::baseUrl() . '/' . $_REQUEST['jsreload']; $json['reload'] = DI::baseUrl() . '/' . $_REQUEST['jsreload'];
} }
echo json_encode($json); System::jsonExit($json);
exit();
} }
if ($orig_post) { if ($orig_post) {
@ -841,8 +839,7 @@ function item_post_return($baseurl, $api_source, $return_path)
Logger::log('post_json: ' . print_r($json, true), Logger::DEBUG); Logger::log('post_json: ' . print_r($json, true), Logger::DEBUG);
echo json_encode($json); System::jsonExit($json);
exit();
} }
function item_content(App $a) function item_content(App $a)
@ -867,8 +864,7 @@ function item_content(App $a)
if (DI::mode()->isAjax()) { if (DI::mode()->isAjax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>] // ajax return: [<item id>, 0 (no perm) | <owner id>]
echo json_encode([intval($a->argv[2]), intval($o)]); System::jsonExit([intval($a->argv[2]), intval($o)]);
exit();
} }
} }