Merge "JavaScriptMinifier: Remove support for unused $statementsOnOwnLine flag"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 24 Dec 2017 21:54:45 +0000 (21:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 24 Dec 2017 21:54:45 +0000 (21:54 +0000)
RELEASE-NOTES-1.31
includes/libs/JavaScriptMinifier.php

index 7f67feb..e6b9fce 100644 (file)
@@ -153,6 +153,9 @@ changes to languages because of Phabricator reports.
   * WatchedItem::IGNORE_USER_RIGHTS
   * WatchedItem::CHECK_USER_RIGHTS
   * WatchedItem::DEPRECATED_USAGE_TIMESTAMP
+* The $statementsOnOwnLine parameter of JavaScriptMinifier::minify was removed.
+  The corresponding configuration variable ($wgResourceLoaderMinifierStatementsOnOwnLine)
+  has been deprecated since 1.27 and was removed as well.
 
 == Compatibility ==
 MediaWiki 1.31 requires PHP 5.5.9 or later. There is experimental support for
index 141a515..3be9ca1 100644 (file)
@@ -74,11 +74,10 @@ class JavaScriptMinifier {
         *       or when required to guard against semicolon insertion.
         *
         * @param string $s JavaScript code to minify
-        * @param bool $statementsOnOwnLine Whether to put each statement on its own line
         * @param int $maxLineLength Maximum length of a single line, or -1 for no maximum.
         * @return String Minified code
         */
-       public static function minify( $s, $statementsOnOwnLine = false, $maxLineLength = 1000 ) {
+       public static function minify( $s, $maxLineLength = 1000 ) {
                // First we declare a few tables that contain our parsing rules
 
                // $opChars : characters, which can be combined without whitespace in between them
@@ -387,23 +386,6 @@ class JavaScriptMinifier {
                        )
                );
 
-               // Rules for when newlines should be inserted if
-               // $statementsOnOwnLine is enabled.
-               // $newlineBefore is checked before switching state,
-               // $newlineAfter is checked after
-               $newlineBefore = array(
-                       self::STATEMENT => array(
-                               self::TYPE_BRACE_CLOSE => true,
-                       ),
-               );
-               $newlineAfter = array(
-                       self::STATEMENT => array(
-                               self::TYPE_BRACE_OPEN => true,
-                               self::TYPE_PAREN_CLOSE => true,
-                               self::TYPE_SEMICOLON => true,
-                       ),
-               );
-
                // $divStates : Contains all states that can be followed by a division operator
                $divStates = array(
                        self::EXPRESSION_OP          => true,
@@ -580,15 +562,6 @@ class JavaScriptMinifier {
                        $pos = $end;
                        $newlineFound = false;
 
-                       // Output a newline after the token if required
-                       // This is checked before AND after switching state
-                       $newlineAdded = false;
-                       if ( $statementsOnOwnLine && !$newlineAdded && isset( $newlineBefore[$state][$type] ) ) {
-                               $out .= "\n";
-                               $lineLength = 0;
-                               $newlineAdded = true;
-                       }
-
                        // Now that we have output our token, transition into the new state.
                        if( isset( $push[$state][$type] ) && count( $stack ) < self::STACK_LIMIT ) {
                                $stack[] = $push[$state][$type];
@@ -598,12 +571,6 @@ class JavaScriptMinifier {
                        } elseif( isset( $goto[$state][$type] ) ) {
                                $state = $goto[$state][$type];
                        }
-
-                       // Check for newline insertion again
-                       if ( $statementsOnOwnLine && !$newlineAdded && isset( $newlineAfter[$state][$type] ) ) {
-                               $out .= "\n";
-                               $lineLength = 0;
-                       }
                }
                return $out;
        }