diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-03-06 00:26:55 +0100 |
---|---|---|
committer | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2024-03-06 10:42:21 +0100 |
commit | ead574ba7fc18be7735b7180b2317c5af1cdc72f (patch) | |
tree | 9345f51a776b880001c34bd2a52bb37f15a7084d /lib/private/legacy | |
parent | 945d97ded1469da0b93285c1817cf5ff4937f88f (diff) | |
download | nextcloud-server-ead574ba7fc18be7735b7180b2317c5af1cdc72f.tar.gz nextcloud-server-ead574ba7fc18be7735b7180b2317c5af1cdc72f.zip |
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>
Diffstat (limited to 'lib/private/legacy')
-rw-r--r-- | lib/private/legacy/OC_API.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/OC_EventSource.php | 4 | ||||
-rw-r--r-- | lib/private/legacy/OC_JSON.php | 14 |
3 files changed, 4 insertions, 16 deletions
diff --git a/lib/private/legacy/OC_API.php b/lib/private/legacy/OC_API.php index 862e73e6edd..facd08c1d2f 100644 --- a/lib/private/legacy/OC_API.php +++ b/lib/private/legacy/OC_API.php @@ -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(); diff --git a/lib/private/legacy/OC_EventSource.php b/lib/private/legacy/OC_EventSource.php index cd72ba1f2d5..49fde4a214f 100644 --- a/lib/private/legacy/OC_EventSource.php +++ b/lib/private/legacy/OC_EventSource.php @@ -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(); diff --git a/lib/private/legacy/OC_JSON.php b/lib/private/legacy/OC_JSON.php index b9cfb8210e0..b6791fe4b85 100644 --- a/lib/private/legacy/OC_JSON.php +++ b/lib/private/legacy/OC_JSON.php @@ -114,22 +114,10 @@ class OC_JSON { } /** - * 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); } } |