Merge "JavaScriptMinifier: Remove support for unused $maxLineLength param"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 18 Jan 2018 04:00:47 +0000 (04:00 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 18 Jan 2018 04:00:47 +0000 (04:00 +0000)
RELEASE-NOTES-1.31
includes/libs/JavaScriptMinifier.php

index 695b88f..a50159c 100644 (file)
@@ -168,6 +168,9 @@ changes to languages because of Phabricator reports.
 * The $statementsOnOwnLine parameter of JavaScriptMinifier::minify was removed.
   The corresponding configuration variable ($wgResourceLoaderMinifierStatementsOnOwnLine)
   has been deprecated since 1.27 and was removed as well.
+* The $maxLineLength parameter of JavaScriptMinifier::minify was removed.
+  The corresponding configuration variable ($wgResourceLoaderMinifierMaxLineLength)
+  has been deprecated since 1.27 and was removed as well.
 * The HtmlFormatter class was removed (deprecated in 1.27). The namespaced
   HtmlFormatter\HtmlFormatter class should be used instead.
 * License::getLicenses has been deprecated; use License::getLines instead.
index 3f46453..a1a93d2 100644 (file)
@@ -63,17 +63,19 @@ class JavaScriptMinifier {
        const STACK_LIMIT = 1000;
 
        /**
-        * Returns minified JavaScript code.
-        *
-        * NOTE: $maxLineLength isn't a strict maximum. Longer lines will be produced when
-        *       literals (e.g. quoted strings) longer than $maxLineLength are encountered
+        * NOTE: This isn't a strict maximum. Longer lines will be produced when
+        *       literals (e.g. quoted strings) longer than this are encountered
         *       or when required to guard against semicolon insertion.
+        */
+       const MAX_LINE_LENGTH = 1000;
+
+       /**
+        * Returns minified JavaScript code.
         *
         * @param string $s JavaScript code to minify
-        * @param int $maxLineLength Maximum length of a single line, or -1 for no maximum.
         * @return String Minified code
         */
-       public static function minify( $s, $maxLineLength = 1000 ) {
+       public static function minify( $s ) {
                // First we declare a few tables that contain our parsing rules
 
                // $opChars : characters, which can be combined without whitespace in between them
@@ -571,7 +573,7 @@ class JavaScriptMinifier {
                                $out .= "\n";
                                $state = self::STATEMENT;
                                $lineLength = 0;
-                       } elseif ( $maxLineLength > 0 && $lineLength + $end - $pos > $maxLineLength &&
+                       } elseif ( $lineLength + $end - $pos > self::MAX_LINE_LENGTH &&
                                        !isset( $semicolon[$state][$type] ) && $type !== self::TYPE_INCR_OP ) {
                                // This line would get too long if we added $token, so add a newline first.
                                // Only do this if it won't trigger semicolon insertion and if it won't