mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 15:18:58 +01:00
instead of sending nothing, which gives a parse error on client-side, send a valid, empty response
This commit is contained in:
parent
596a01a76d
commit
207b7de248
@ -240,8 +240,6 @@ class egw_json_response
|
||||
call_user_func_array($proc['proc'], $proc['params']);
|
||||
}
|
||||
|
||||
//$inst->sendHeader();
|
||||
|
||||
// check if application made some direct output
|
||||
if (($output = ob_get_clean()))
|
||||
{
|
||||
@ -256,11 +254,8 @@ class egw_json_response
|
||||
}
|
||||
}
|
||||
|
||||
if($inst->haveJSONResponse())
|
||||
{
|
||||
echo $inst->getJSON();
|
||||
$inst->initResponseArray();
|
||||
}
|
||||
echo $inst->getJSON();
|
||||
$inst->initResponseArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -532,6 +527,25 @@ class egw_json_response
|
||||
return json_encode($res); //PHP5.3+, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
|
||||
}
|
||||
|
||||
public function json_encode($var)
|
||||
{
|
||||
$ret = json_encode($var);
|
||||
|
||||
if (($err = json_last_error()))
|
||||
{
|
||||
static $json_err2str = array(
|
||||
JSON_ERROR_NONE => 'No errors',
|
||||
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
|
||||
JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch',
|
||||
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
|
||||
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
|
||||
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded',
|
||||
);
|
||||
error_log(__METHOD__.'('.array2string($var).') json_last_error()='.$err.'='.$json_err2str[$err]);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function which can be used to add an event listener callback function to
|
||||
* the "beforeSendData" callback. This callback might be used to add a response
|
||||
|
Loading…
Reference in New Issue
Block a user