From bb52950fee26ba2895aadeba0bf7d08fa66dfdd8 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Sun, 16 Apr 2017 23:32:02 +0200 Subject: [PATCH] Remove workaround for PHP bug 66021 (PHP < 5.5.12) The PHP bug 66021 was fixed by https://github.com/php/php-src/pull/518 and is included in PHP 5.4.28+ and PHP 5.5.12+. This workaround is not necessary anymore because the minimum PHP version for MediaWiki is 7.0.0+. Change-Id: I801eaffc253fd88e0d3c87cfe97777837bd3902d --- includes/json/FormatJson.php | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php index 0c77a7bcc2..acbbf2604f 100644 --- a/includes/json/FormatJson.php +++ b/includes/json/FormatJson.php @@ -77,17 +77,6 @@ class FormatJson { */ const STRIP_COMMENTS = 0x400; - /** - * Regex that matches whitespace inside empty arrays and objects. - * - * This doesn't affect regular strings inside the JSON because those can't - * have a real line break (\n) in them, at this point they are already escaped - * as the string "\n" which this doesn't match. - * - * @private - */ - const WS_CLEANUP_REGEX = '/(?<=[\[{])\n\s*+(?=[\]}])/'; - /** * Characters problematic in JavaScript. * @@ -129,11 +118,6 @@ class FormatJson { $pretty = $pretty ? ' ' : false; } - static $bug66021; - if ( $pretty !== false && $bug66021 === null ) { - $bug66021 = json_encode( [], JSON_PRETTY_PRINT ) !== '[]'; - } - // PHP escapes '/' to prevent breaking out of inline script blocks using '', // which is hardly useful when '<' and '>' are escaped (and inadequate), and such // escaping negatively impacts the human readability of URLs and similar strings. @@ -147,10 +131,6 @@ class FormatJson { } if ( $pretty !== false ) { - // Workaround for - if ( $bug66021 ) { - $json = preg_replace( self::WS_CLEANUP_REGEX, '', $json ); - } if ( $pretty !== ' ' ) { // Change the four-space indent to a tab indent $json = str_replace( "\n ", "\n\t", $json ); -- 2.20.1