Skip to content

Commit

Permalink
Merge pull request #8791 from nextcloud/cleanup-oc_json
Browse files Browse the repository at this point in the history
Remove unused methods of OC_Json
  • Loading branch information
MorrisJobke authored Mar 22, 2018
2 parents dc4ba31 + 78211a5 commit be35b54
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 39 deletions.
4 changes: 2 additions & 2 deletions lib/private/legacy/eventsource.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ public function send($type, $data = null) {
}
if ($this->fallback) {
$response = '<script type="text/javascript">window.parent.OC.EventSource.fallBackCallBack('
. $this->fallBackId . ',"' . $type . '",' . OCP\JSON::encode($data) . ')</script>' . PHP_EOL;
. $this->fallBackId . ',"' . $type . '",' . OC_JSON::encode($data) . ')</script>' . PHP_EOL;
echo $response;
} else {
if ($type) {
echo 'event: ' . $type . PHP_EOL;
}
echo 'data: ' . OCP\JSON::encode($data) . PHP_EOL;
echo 'data: ' . OC_JSON::encode($data) . PHP_EOL;
}
echo PHP_EOL;
flush();
Expand Down
30 changes: 4 additions & 26 deletions lib/private/legacy/json.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@
* @deprecated Use a AppFramework JSONResponse instead
*/
class OC_JSON{
static protected $send_content_type_header = false;
/**
* set Content-Type header to jsonrequest
* @deprecated Use a AppFramework JSONResponse instead
*/
public static function setContentTypeHeader($type='application/json') {
if (!self::$send_content_type_header) {
// We send json data
header( 'Content-Type: '.$type . '; charset=utf-8');
self::$send_content_type_header = true;
}
}

/**
* Check if the app is enabled, send json error msg if not
Expand Down Expand Up @@ -137,7 +125,8 @@ public static function checkSubAdminUser() {
*/
public static function error($data = array()) {
$data['status'] = 'error';
self::encodedPrint($data);
header( 'Content-Type: application/json; charset=utf-8');
echo self::encode($data);
}

/**
Expand All @@ -147,7 +136,8 @@ public static function error($data = array()) {
*/
public static function success($data = array()) {
$data['status'] = 'success';
self::encodedPrint($data);
header( 'Content-Type: application/json; charset=utf-8');
echo self::encode($data);
}

/**
Expand All @@ -159,18 +149,6 @@ protected static function to_string(&$value) {
}
}

/**
* Encode and print $data in json format
* @deprecated Use a AppFramework JSONResponse instead
* @suppress PhanDeprecatedFunction
*/
public static function encodedPrint($data, $setContentType=true) {
if($setContentType) {
self::setContentTypeHeader();
}
echo self::encode($data);
}

/**
* Encode JSON
* @deprecated Use a AppFramework JSONResponse instead
Expand Down
11 changes: 0 additions & 11 deletions lib/public/JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,4 @@ public static function checkAppEnabled( $app ) {
public static function checkAdminUser() {
\OC_JSON::checkAdminUser();
}

/**
* Encode JSON
* @param array $data
* @return string
* @deprecated 8.1.0 Use a AppFramework JSONResponse instead
* @suppress PhanDeprecatedFunction
*/
public static function encode($data) {
return \OC_JSON::encode($data);
}
}

0 comments on commit be35b54

Please sign in to comment.