http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89706

Revision: 89706
Author:   platonides
Date:     2011-06-07 22:28:57 +0000 (Tue, 07 Jun 2011)
Log Message:
-----------
Reinstate r79122 (fix for bug 14404), reverting r83868. The real bug seem to 
have been r86131, fixed in r88902 (1.17) and  r88902 (1.18).
This is not merged with the r86131 change to Article::getParserOptions() since 
I don't see the point for the new function yet.
Reenabled its test ArticleTablesTest which was disabled in r85618

Modified Paths:
--------------
    trunk/phase3/includes/Article.php
    trunk/phase3/tests/phpunit/includes/ArticleTablesTest.php

Modified: trunk/phase3/includes/Article.php
===================================================================
--- trunk/phase3/includes/Article.php   2011-06-07 22:21:52 UTC (rev 89705)
+++ trunk/phase3/includes/Article.php   2011-06-07 22:28:57 UTC (rev 89706)
@@ -63,7 +63,7 @@
        var $mTouched = '19700101000000'; // !<
 
        /**
-        * @var ParserOptions
+        * @var ParserOptions: ParserOptions object for $wgUser articles
         */
        var $mParserOptions;
 
@@ -3541,7 +3541,7 @@
                $edit->revid = $revid;
                $edit->newText = $text;
                $edit->pst = $this->preSaveTransform( $text, $user, $popts );
-               $edit->popts = $this->getParserOptions();
+               $edit->popts = $this->getParserOptions( true );
                $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, 
$edit->popts, true, true, $revid );
                $edit->oldText = $this->getRawText();
 
@@ -4329,12 +4329,23 @@
 
        /**
         * Get parser options suitable for rendering the primary article 
wikitext
-        * @return ParserOptions object
+        * @param $canonical boolean Determines that the generated options must 
not depend on user preferences (see bug 14404)
+        * @return mixed ParserOptions object or boolean false
         */
-       public function getParserOptions() {
-               global $wgUser;
-               if ( !$this->mParserOptions ) {
-                       $this->mParserOptions = $this->makeParserOptions( 
$wgUser );
+       public function getParserOptions( $canonical = false ) {
+               global $wgUser, $wgLanguageCode;
+
+               if ( !$this->mParserOptions || $canonical ) {
+                       $user = !$canonical ? $wgUser : new User;
+                       $parserOptions = new ParserOptions( $user );
+                       $parserOptions->setTidy( true );
+                       $parserOptions->enableLimitReport();
+
+                       if ( $canonical ) {
+                               $parserOptions->setUserLang( $wgLanguageCode ); 
# Must be set explicitely
+                               return $parserOptions;
+                       }
+                       $this->mParserOptions = $parserOptions;
                }
                // Clone to allow modifications of the return value without 
affecting cache
                return clone $this->mParserOptions;

Modified: trunk/phase3/tests/phpunit/includes/ArticleTablesTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/ArticleTablesTest.php   2011-06-07 
22:21:52 UTC (rev 89705)
+++ trunk/phase3/tests/phpunit/includes/ArticleTablesTest.php   2011-06-07 
22:28:57 UTC (rev 89706)
@@ -5,9 +5,7 @@
  * @group Destructive
  */
 class ArticleTablesTest extends MediaWikiLangTestCase {
-       /**
-        * @group Broken
-        */
+
        function testbug14404() {
                global $wgUser, $wgContLang, $wgLanguageCode, $wgLang;
                


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to