fix: Remove calls to deprecated OC_JSON::encode

to_string was useless because L10N string is json serializable now and
serialize to string correctly. Removed all external calls to
OC_JSON::encode to ease removing the rest of it later.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/44015/head
Côme Chilliet 3 months ago committed by Côme Chilliet
parent 945d97ded1
commit ead574ba7f

@ -171,7 +171,7 @@ class OC_API {
],
];
if ($format == 'json') {
return OC_JSON::encode($response);
return json_encode($response, JSON_HEX_TAG);
}
$writer = new XMLWriter();

@ -113,13 +113,13 @@ class OC_EventSource implements \OCP\IEventSource {
}
if ($this->fallback) {
$response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
. $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
. $this->fallBackId . ',"' . ($type ?? '') . '",' . json_encode($data, JSON_HEX_TAG) . ')</script>' . PHP_EOL;
echo $response;
} else {
if ($type) {
echo 'event: ' . $type . PHP_EOL;
}
echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
echo 'data: ' . json_encode($data, JSON_HEX_TAG) . PHP_EOL;
}
echo PHP_EOL;
flush();

@ -113,23 +113,11 @@ class OC_JSON {
echo self::encode($data);
}
/**
* Convert OC_L10N_String to string, for use in json encodings
*/
protected static function to_string(&$value) {
if ($value instanceof \OC\L10N\L10NString) {
$value = (string)$value;
}
}
/**
* Encode JSON
* @deprecated Use a AppFramework JSONResponse instead
*/
public static function encode($data) {
if (is_array($data)) {
array_walk_recursive($data, ['OC_JSON', 'to_string']);
}
private static function encode($data) {
return json_encode($data, JSON_HEX_TAG);
}
}

Loading…
Cancel
Save