From 28e7830d789446fc30ce43ed283f2a16d6031478 Mon Sep 17 00:00:00 2001 From: Reedy Date: Sun, 12 Aug 2012 20:31:01 +0100 Subject: [PATCH] PHP 5.4 has JSON_PRETTY_PRINT Use this conditionally when $isHtml is true, and is also running on PHP > = 5.4. Else return default 0 Change-Id: Ief775720a99d1a305c3f9f4ba7cc04eb96817fb3 --- includes/json/FormatJson.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php index bbcc1856bd..aa60fbdcc0 100644 --- a/includes/json/FormatJson.php +++ b/includes/json/FormatJson.php @@ -41,11 +41,11 @@ class FormatJson { * @return string */ public static function encode( $value, $isHtml = false ) { - if ( !function_exists( 'json_encode' ) || $isHtml ) { + if ( !function_exists( 'json_encode' ) || ( $isHtml && version_compare( PHP_VERSION, '5.4.0', '<' ) ) ) { $json = new Services_JSON(); return $json->encode( $value, $isHtml ); } else { - return json_encode( $value ); + return json_encode( $value, $isHtml ? JSON_PRETTY_PRINT : 0 ); } } -- 2.20.1