Thcipriani has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/353584 )

Change subject: Revert "Wrap parser output in <div class="mw-parser-output">"
......................................................................

Revert "Wrap parser output in <div class="mw-parser-output">"

This reverts commit 1aac0a2992e3bbec0436c5e01e00bfc4fef3ccc2.

Change-Id: I8be7e6dbb68e279df90a5999be8659247a45a9c4
---
M RELEASE-NOTES-1.30
M includes/api/ApiParse.php
M includes/api/i18n/en.json
M includes/api/i18n/qqq.json
M includes/cache/MessageCache.php
M includes/parser/Parser.php
M includes/parser/ParserOptions.php
M tests/parser/ParserTestRunner.php
M tests/parser/parserTests.txt
M tests/phpunit/includes/ExtraParserTest.php
M tests/phpunit/includes/content/WikitextContentTest.php
M tests/phpunit/includes/page/WikiPageTest.php
M tests/phpunit/includes/parser/TagHooksTest.php
13 files changed, 12 insertions(+), 83 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/84/353584/1

diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30
index 27acb8a..7f018a8 100644
--- a/RELEASE-NOTES-1.30
+++ b/RELEASE-NOTES-1.30
@@ -19,9 +19,6 @@
   to allow for proper dependency injection.
 
 === New features in 1.30 ===
-* (T37247) Output from Parser::parse() will now be wrapped in a div with
-  class="mw-parser-output" by default. This may be changed or disabled using
-  ParserOptions::setWrapOutputClass().
 * Added 'ChangeTagsAllowedAdd' hook, enabling extensions to allow software-
   specific tags to be added by users.
 * File storage backends that supports headers (eg. Swift) now store an
@@ -43,9 +40,7 @@
 * …
 
 === Action API changes in 1.30 ===
-* (T37247) action=parse output will be wrapped in a div with
-  class="mw-parser-output" by default. This may be changed or disabled using
-  the new 'wrapoutputclass' parameter.
+* …
 
 === Action API internal changes in 1.30 ===
 * …
diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php
index 7d22d9c..d648968 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -478,9 +478,6 @@
                if ( $params['disabletidy'] ) {
                        $popts->setTidy( false );
                }
-               $popts->setWrapOutputClass(
-                       $params['wrapoutputclass'] === '' ? false : 
$params['wrapoutputclass']
-               );
 
                $reset = null;
                $suppressCache = false;
@@ -791,7 +788,6 @@
                                        'parsetree' => [ 
'apihelp-parse-paramvalue-prop-parsetree', CONTENT_MODEL_WIKITEXT ],
                                ],
                        ],
-                       'wrapoutputclass' => 'mw-parser-output',
                        'pst' => false,
                        'onlypst' => false,
                        'effectivelanglinks' => false,
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index c3c7bd4..81bac02 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -349,7 +349,6 @@
        "apihelp-parse-paramvalue-prop-limitreporthtml": "Gives the HTML 
version of the limit report. Gives no data, when 
<var>$1disablelimitreport</var> is set.",
        "apihelp-parse-paramvalue-prop-parsetree": "The XML parse tree of 
revision content (requires content model <code>$1</code>)",
        "apihelp-parse-paramvalue-prop-parsewarnings": "Gives the warnings that 
occurred while parsing content.",
-       "apihelp-parse-param-wrapoutputclass": "CSS class to use to wrap the 
parser output.",
        "apihelp-parse-param-pst": "Do a pre-save transform on the input before 
parsing it. Only valid when used with text.",
        "apihelp-parse-param-onlypst": "Do a pre-save transform (PST) on the 
input, but don't parse it. Returns the same wikitext, after a PST has been 
applied. Only valid when used with <var>$1text</var>.",
        "apihelp-parse-param-effectivelanglinks": "Includes language links 
supplied by extensions (for use with <kbd>$1prop=langlinks</kbd>).",
diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json
index da0b22d..6ae87be 100644
--- a/includes/api/i18n/qqq.json
+++ b/includes/api/i18n/qqq.json
@@ -331,7 +331,6 @@
        "apihelp-parse-paramvalue-prop-limitreporthtml": 
"{{doc-apihelp-paramvalue|parse|prop|limitreporthtml}}",
        "apihelp-parse-paramvalue-prop-parsetree": 
"{{doc-apihelp-paramvalue|parse|prop|parsetree|params=* $1 - Value of the 
constant CONTENT_MODEL_WIKITEXT|paramstart=2}}",
        "apihelp-parse-paramvalue-prop-parsewarnings": 
"{{doc-apihelp-paramvalue|parse|prop|parsewarnings}}",
-       "apihelp-parse-param-wrapoutputclass": 
"{{doc-apihelp-param|parse|wrapoutputclass}}",
        "apihelp-parse-param-pst": "{{doc-apihelp-param|parse|pst}}",
        "apihelp-parse-param-onlypst": "{{doc-apihelp-param|parse|onlypst}}",
        "apihelp-parse-param-effectivelanglinks": 
"{{doc-apihelp-param|parse|effectivelanglinks}}",
diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php
index 8f88ee9..254b1ff 100644
--- a/includes/cache/MessageCache.php
+++ b/includes/cache/MessageCache.php
@@ -193,7 +193,6 @@
                                $po = ParserOptions::newFromAnon();
                                $po->setEditSection( false );
                                $po->setAllowUnsafeRawHtml( false );
-                               $po->setWrapOutputClass( false );
                                return $po;
                        }
 
@@ -203,11 +202,6 @@
                        // from malicious sources. As a precaution, disable
                        // the <html> parser tag when parsing messages.
                        $this->mParserOptions->setAllowUnsafeRawHtml( false );
-                       // Wrapping messages in an extra <div> is probably not 
expected. If
-                       // they're outside the content area they probably 
shouldn't be
-                       // targeted by CSS that's targeting the parser output, 
and if
-                       // they're inside they already are from the outer div.
-                       $this->mParserOptions->setWrapOutputClass( false );
                }
 
                return $this->mParserOptions;
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index ecee0e2..5b1e86d 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -589,14 +589,6 @@
                                        $this->mTitle->getPrefixedDBkey() );
                        }
                }
-
-               # Wrap non-interface parser output in a <div> so it can be 
targeted
-               # with CSS (T37247)
-               $class = $this->mOptions->getWrapOutputClass();
-               if ( $class !== false && 
!$this->mOptions->getInterfaceMessage() ) {
-                       $text = Html::rawElement( 'div', [ 'class' => $class ], 
$text );
-               }
-
                $this->mOutput->setText( $text );
 
                $this->mRevisionId = $oldRevisionId;
diff --git a/includes/parser/ParserOptions.php 
b/includes/parser/ParserOptions.php
index d4d1042..2cdd8c7 100644
--- a/includes/parser/ParserOptions.php
+++ b/includes/parser/ParserOptions.php
@@ -258,12 +258,6 @@
         */
        private $allowUnsafeRawHtml = true;
 
-       /**
-        * CSS class to use to wrap output from Parser::parse().
-        * @var string|false
-        */
-       private $wrapOutputClass = 'mw-parser-output';
-
        public function getInterwikiMagic() {
                return $this->mInterwikiMagic;
        }
@@ -487,15 +481,6 @@
                return $this->allowUnsafeRawHtml;
        }
 
-       /**
-        * Class to use to wrap output from Parser::parse()
-        * @since 1.30
-        * @return string|bool
-        */
-       public function getWrapOutputClass() {
-               return $this->wrapOutputClass;
-       }
-
        public function setInterwikiMagic( $x ) {
                return wfSetVar( $this->mInterwikiMagic, $x );
        }
@@ -642,19 +627,6 @@
         */
        public function setAllowUnsafeRawHtml( $x ) {
                return wfSetVar( $this->allowUnsafeRawHtml, $x );
-       }
-
-       /**
-        * CSS class to use to wrap output from Parser::parse()
-        * @since 1.30
-        * @param string|bool $className Set false to disable wrapping.
-        * @return string|bool Current value
-        */
-       public function setWrapOutputClass( $className ) {
-               if ( $className === true ) { // DWIM, they probably want the 
default class name
-                       $className = 'mw-parser-output';
-               }
-               return wfSetVar( $this->wrapOutputClass, $className );
        }
 
        /**
diff --git a/tests/parser/ParserTestRunner.php 
b/tests/parser/ParserTestRunner.php
index f44b0d5..f100411 100644
--- a/tests/parser/ParserTestRunner.php
+++ b/tests/parser/ParserTestRunner.php
@@ -747,10 +747,6 @@
                $user = $context->getUser();
                $options = ParserOptions::newFromContext( $context );
 
-               if ( !isset( $opts['wrap'] ) ) {
-                       $options->setWrapOutputClass( false );
-               }
-
                if ( isset( $opts['tidy'] ) ) {
                        if ( !$this->tidySupport->isEnabled() ) {
                                $this->recorder->skipped( $test, 'tidy 
extension is not installed' );
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index 6477356..e12c136 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -32,7 +32,6 @@
 # local         format section links in edit comment text as local links
 # notoc         disable table of contents
 # thumbsize=NNN set the default thumb size to NNNpx for this test
-# wrap          include the normal wrapper <div class="mw-parser-output"> 
(since 1.30)
 #
 # You can also set the following parser properties via test options:
 #  wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
diff --git a/tests/phpunit/includes/ExtraParserTest.php 
b/tests/phpunit/includes/ExtraParserTest.php
index a4e3bb9..4e95a30 100644
--- a/tests/phpunit/includes/ExtraParserTest.php
+++ b/tests/phpunit/includes/ExtraParserTest.php
@@ -26,7 +26,6 @@
                // FIXME: This test should pass without setting global content 
language
                $this->options = ParserOptions::newFromUserAndLang( new User, 
$contLang );
                $this->options->setTemplateCallback( [ __CLASS__, 
'statelessFetchTemplate' ] );
-               $this->options->setWrapOutputClass( false );
                $this->parser = new Parser;
 
                MagicWord::clearCache();
@@ -41,7 +40,6 @@
 
                $title = Title::newFromText( 'Unit test' );
                $options = ParserOptions::newFromUser( new User() );
-               $options->setWrapOutputClass( false );
                $this->assertEquals( "<p>$longLine</p>",
                        $this->parser->parse( $longLine, $title, $options 
)->getText() );
        }
diff --git a/tests/phpunit/includes/content/WikitextContentTest.php 
b/tests/phpunit/includes/content/WikitextContentTest.php
index b9ce997..4c69d87 100644
--- a/tests/phpunit/includes/content/WikitextContentTest.php
+++ b/tests/phpunit/includes/content/WikitextContentTest.php
@@ -29,7 +29,7 @@
                                "WikitextContentTest_testGetParserOutput",
                                CONTENT_MODEL_WIKITEXT,
                                "hello ''world''\n",
-                               "<div class=\"mw-parser-output\"><p>hello 
<i>world</i>\n</p>\n\n\n</div>"
+                               "<p>hello <i>world</i>\n</p>"
                        ],
                        // TODO: more...?
                ];
diff --git a/tests/phpunit/includes/page/WikiPageTest.php 
b/tests/phpunit/includes/page/WikiPageTest.php
index 556a348..6b911bf 100644
--- a/tests/phpunit/includes/page/WikiPageTest.php
+++ b/tests/phpunit/includes/page/WikiPageTest.php
@@ -549,11 +549,7 @@
 
        public static function provideGetParserOutput() {
                return [
-                       [
-                               CONTENT_MODEL_WIKITEXT,
-                               "hello ''world''\n",
-                               "<div class=\"mw-parser-output\"><p>hello 
<i>world</i></p></div>"
-                       ],
+                       [ CONTENT_MODEL_WIKITEXT, "hello ''world''\n", 
"<p>hello <i>world</i></p>" ],
                        // @todo more...?
                ];
        }
@@ -570,7 +566,7 @@
                $text = $po->getText();
 
                $text = trim( preg_replace( '/<!--.*?-->/sm', '', $text ) ); # 
strip injected comments
-               $text = preg_replace( '!\s*(</p>|</div>)!sm', '\1', $text ); # 
don't let tidy confuse us
+               $text = preg_replace( '!\s*(</p>)!sm', '\1', $text ); # don't 
let tidy confuse us
 
                $this->assertEquals( $expectedHtml, $text );
 
diff --git a/tests/phpunit/includes/parser/TagHooksTest.php 
b/tests/phpunit/includes/parser/TagHooksTest.php
index 06fe272..12936ee 100644
--- a/tests/phpunit/includes/parser/TagHooksTest.php
+++ b/tests/phpunit/includes/parser/TagHooksTest.php
@@ -43,25 +43,18 @@
                return [ [ "foo<bar" ], [ "foo>bar" ], [ "foo\nbar" ], [ 
"foo\rbar" ] ];
        }
 
-       private function getParserOptions() {
-               global $wgContLang;
-               $popt = ParserOptions::newFromUserAndLang( new User, 
$wgContLang );
-               $popt->setWrapOutputClass( false );
-               return $popt;
-       }
-
        /**
         * @dataProvider provideValidNames
         */
        public function testTagHooks( $tag ) {
-               global $wgParserConf;
+               global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
 
                $parser->setHook( $tag, [ $this, 'tagCallback' ] );
                $parserOutput = $parser->parse(
                        "Foo<$tag>Bar</$tag>Baz",
                        Title::newFromText( 'Test' ),
-                       $this->getParserOptions()
+                       ParserOptions::newFromUserAndLang( new User, 
$wgContLang )
                );
                $this->assertEquals( "<p>FooOneBaz\n</p>", 
$parserOutput->getText() );
 
@@ -73,14 +66,14 @@
         * @expectedException MWException
         */
        public function testBadTagHooks( $tag ) {
-               global $wgParserConf;
+               global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
 
                $parser->setHook( $tag, [ $this, 'tagCallback' ] );
                $parser->parse(
                        "Foo<$tag>Bar</$tag>Baz",
                        Title::newFromText( 'Test' ),
-                       $this->getParserOptions()
+                       ParserOptions::newFromUserAndLang( new User, 
$wgContLang )
                );
                $this->fail( 'Exception not thrown.' );
        }
@@ -89,14 +82,14 @@
         * @dataProvider provideValidNames
         */
        public function testFunctionTagHooks( $tag ) {
-               global $wgParserConf;
+               global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
 
                $parser->setFunctionTagHook( $tag, [ $this, 
'functionTagCallback' ], 0 );
                $parserOutput = $parser->parse(
                        "Foo<$tag>Bar</$tag>Baz",
                        Title::newFromText( 'Test' ),
-                       $this->getParserOptions()
+                       ParserOptions::newFromUserAndLang( new User, 
$wgContLang )
                );
                $this->assertEquals( "<p>FooOneBaz\n</p>", 
$parserOutput->getText() );
 
@@ -108,7 +101,7 @@
         * @expectedException MWException
         */
        public function testBadFunctionTagHooks( $tag ) {
-               global $wgParserConf;
+               global $wgParserConf, $wgContLang;
                $parser = new Parser( $wgParserConf );
 
                $parser->setFunctionTagHook(
@@ -119,7 +112,7 @@
                $parser->parse(
                        "Foo<$tag>Bar</$tag>Baz",
                        Title::newFromText( 'Test' ),
-                       $this->getParserOptions()
+                       ParserOptions::newFromUserAndLang( new User, 
$wgContLang )
                );
                $this->fail( 'Exception not thrown.' );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/353584
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8be7e6dbb68e279df90a5999be8659247a45a9c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.30.0-wmf.1
Gerrit-Owner: Thcipriani <tcipri...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to