Revert r36093 (bug 14404).
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 11 Jun 2008 02:51:30 +0000 (02:51 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 11 Jun 2008 02:51:30 +0000 (02:51 +0000)
Regressions caused by this:
"Use an anonymous user to get the parser options and the parser cache key, thus wikitext rendering is not depending of some sepcific user options such as lang, ..."

User-specific options such as stub threshold were still applying in the parser, but not taken into account in the parser hash key. As a result, the caches were corrupt, saving different options into the anonymous-default options cache.

RELEASE-NOTES
includes/Article.php
includes/CoreParserFunctions.php
includes/ParserCache.php
includes/ParserOptions.php
includes/RefreshLinksJob.php
includes/User.php

index 9215660..517faee 100644 (file)
@@ -351,8 +351,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 14401) Fix Safari access key tooltips for Windows and >3.1 Mac versions
 * (bug 14432) Fix notice regression in Special:Newpages feed mode
 * (bug 11951) EditPage::getEditToolbar() is now static.
-* (bug 14404) Use of {{int:...}} to generate links no longer breaks links table
-  if user has a custom interface language
 * (bug 14392) Fix regression breaking table prefix in installer
 * (bug 11084) $wgDBprefix replacement for updater SQL will now work for
   extension tables using uppercase letters or digits in their names.
index 0fa49e4..d709f62 100644 (file)
@@ -541,9 +541,9 @@ class Article {
         */
        function isRedirect( $text = false ) {
                if ( $text === false ) {
-                       if ( $this->mDataLoaded )
+                       if ( $this->mDataLoaded ) 
                                return $this->mIsRedirect;
-
+                       
                        // Apparently loadPageData was never called
                        $this->loadContent();
                        $titleObj = Title::newFromRedirect( $this->fetchContent() );
@@ -922,14 +922,14 @@ class Article {
                $this->viewUpdates();
                wfProfileOut( __METHOD__ );
        }
-
+       
        protected function viewRedirect( $target, $overwriteSubtitle = true, $forceKnown = false ) {
                global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
-
+               
                # Display redirect
                $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
                $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
-
+               
                if( $overwriteSubtitle ) {
                        $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) );
                }
@@ -941,7 +941,7 @@ class Article {
 
                $wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
                        '<span class="redirectText">'.$link.'</span>' );
-
+               
        }
 
        function addTrackbacks() {
@@ -1449,7 +1449,7 @@ class Article {
 
                                # Update page
                                $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision );
-
+                               
                                wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId) );
 
                                if( !$ok ) {
@@ -1521,7 +1521,7 @@ class Article {
 
                        # Update the page record with revision data
                        $this->updateRevisionOn( $dbw, $revision, 0 );
-
+                       
                        wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
 
                        if( !( $flags & EDIT_SUPPRESS_RC ) ) {
@@ -1881,7 +1881,7 @@ class Article {
                                                'page_id' => $id
                                        ), 'Article::protect'
                                );
-
+                               
                                wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) );
                                wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) );
 
@@ -2242,7 +2242,7 @@ class Article {
        function doDelete( $reason, $suppress = false ) {
                global $wgOut, $wgUser;
                wfDebug( __METHOD__."\n" );
-
+               
                $id = $this->getId();
 
                if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) {
@@ -2514,14 +2514,14 @@ class Article {
                if( empty( $summary ) ){
                        $summary = wfMsgForContent( 'revertpage' );
                }
-
+               
                # Allow the custom summary to use the same args as the default message
                $args = array(
                        $target->getUserText(), $from, $s->rev_id,
                        $wgLang->timeanddate(wfTimestamp(TS_MW, $s->rev_timestamp), true),
                        $current->getId(), $wgLang->timeanddate($current->getTimestamp())
                );
-               $summary = wfMsgReplaceArgs( $summary, $args );
+               $summary = wfMsgReplaceArgs( $summary, $args ); 
 
                # Save
                $flags = EDIT_UPDATE;
@@ -2609,7 +2609,7 @@ class Article {
                        . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
                $wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
                $wgOut->returnToMain( false, $this->mTitle );
-
+               
                if( !$wgRequest->getBool( 'hidediff', false ) ) {
                        $de = new DifferenceEngine( $this->mTitle, $current->getId(), 'next', false, true );
                        $de->showDiff( '', '' );
@@ -2640,7 +2640,7 @@ class Article {
 
        /**
         * Prepare text which is about to be saved.
-        * Returns a stdclass with source, pst, output and user members
+        * Returns a stdclass with source, pst and output members
         */
        function prepareTextForEdit( $text, $revid=null ) {
                if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) {
@@ -2652,14 +2652,11 @@ class Article {
                $edit->revid = $revid;
                $edit->newText = $text;
                $edit->pst = $this->preSaveTransform( $text );
-               $user = new User();
-               $options = new ParserOptions( $user );
+               $options = new ParserOptions;
                $options->setTidy( true );
-               $options->setInterfaceMessage( true ); // @bug 14404
                $options->enableLimitReport();
                $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $options, true, true, $revid );
                $edit->oldText = $this->getContent();
-               $edit->user = $user;
                $this->mPreparedEdit = $edit;
                return $edit;
        }
@@ -2695,7 +2692,7 @@ class Article {
                # Save it to the parser cache
                if ( $wgEnableParserCache ) {
                        $parserCache = ParserCache::singleton();
-                       $parserCache->save( $editInfo->output, $this, $editInfo->user, /*content*/true );
+                       $parserCache->save( $editInfo->output, $this, $wgUser );
                }
 
                # Update the links tables
@@ -2984,7 +2981,7 @@ class Article {
                $revision->insertOn( $dbw );
                $this->updateRevisionOn( $dbw, $revision );
                $dbw->commit();
-
+               
                wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
 
                wfProfileOut( __METHOD__ );
index 60dce19..d9072e9 100644 (file)
@@ -56,15 +56,7 @@ class CoreParserFunctions {
        static function intFunction( $parser, $part1 = '' /*, ... */ ) {
                if ( strval( $part1 ) !== '' ) {
                        $args = array_slice( func_get_args(), 2 );
-                       $opts = array();
-                       if( ( $langObj = $parser->mOptions->getTargetLanguage() ) !== null ){
-                               $opts['language'] = $langObj->getCode();
-                       } else if( $parser->mOptions->getInterfaceMessage() ) {
-                               $opts[] = 'content';
-                       }
-                       $msg = call_user_func_array( 'wfMsgExt', 
-                               array_merge( array( $part1, $opts ), $args ) );
-                       return $parser->replaceVariables( $msg );
+                       return wfMsgReal( $part1, $args, true );
                } else {
                        return array( 'found' => false );
                }
index 72d4c60..bf11da2 100644 (file)
@@ -26,9 +26,9 @@ class ParserCache {
                $this->mMemc =& $memCached;
        }
 
-       function getKey( &$article, &$user, $content = false ) {
+       function getKey( &$article, &$user ) {
                global $action;
-               $hash = $user->getPageRenderingHash( $content );
+               $hash = $user->getPageRenderingHash();
                if( !$article->mTitle->quickUserCan( 'edit' ) ) {
                        // section edit links are suppressed even if the user has them on
                        $edit = '!edit=0';
@@ -86,9 +86,9 @@ class ParserCache {
                return $value;
        }
 
-       function save( $parserOutput, &$article, &$user, $content = false ){
+       function save( $parserOutput, &$article, &$user ){
                global $wgParserCacheExpireTime;
-               $key = $this->getKey( $article, $user, $content );
+               $key = $this->getKey( $article, $user );
 
                if( $parserOutput->getCacheTime() != -1 ) {
 
index 4fd7ca2..330ec44 100644 (file)
@@ -5,31 +5,32 @@
  * @todo document
  * @ingroup Parser
  */
-class ParserOptions {
+class ParserOptions
+{
        # All variables are supposed to be private in theory, although in practise this is not the case.
-       var $mUseTeX;                    //!< Use texvc to expand <math> tags
-       var $mUseDynamicDates;           //!< Use DateFormatter to format dates
-       var $mInterwikiMagic;            //!< Interlanguage links are removed and returned in an array
-       var $mAllowExternalImages;       //!< Allow external images inline
-       var $mAllowExternalImagesFrom;   //!< If not, any exception?
-       var $mSkin;                      //!< Reference to the preferred skin
-       var $mDateFormat;                //!< Date format index
-       var $mEditSection;               //!< Create "edit section" links
-       var $mNumberHeadings;            //!< Automatically number headings
-       var $mAllowSpecialInclusion;     //!< Allow inclusion of special pages
-       var $mTidy;                      //!< Ask for tidy cleanup
-       var $mInterfaceMessage;          //!< Which lang to call for PLURAL and GRAMMAR
-       var $mTargetLanguage;            //!< Overrides above setting with arbitrary language
-       var $mMaxIncludeSize;            //!< Maximum size of template expansions, in bytes
-       var $mMaxPPNodeCount;            //!< Maximum number of nodes touched by PPFrame::expand()
-       var $mMaxPPExpandDepth;          //!< Maximum recursion depth in PPFrame::expand()
-       var $mMaxTemplateDepth;          //!< Maximum recursion depth for templates within templates
-       var $mRemoveComments;            //!< Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
-       var $mTemplateCallback;          //!< Callback for template fetching
-       var $mEnableLimitReport;         //!< Enable limit report in an HTML comment on output
-       var $mTimestamp;                 //!< Timestamp used for {{CURRENTDAY}} etc.
+       var $mUseTeX;                    # Use texvc to expand <math> tags
+       var $mUseDynamicDates;           # Use DateFormatter to format dates
+       var $mInterwikiMagic;            # Interlanguage links are removed and returned in an array
+       var $mAllowExternalImages;       # Allow external images inline
+       var $mAllowExternalImagesFrom;   # If not, any exception?
+       var $mSkin;                      # Reference to the preferred skin
+       var $mDateFormat;                # Date format index
+       var $mEditSection;               # Create "edit section" links
+       var $mNumberHeadings;            # Automatically number headings
+       var $mAllowSpecialInclusion;     # Allow inclusion of special pages
+       var $mTidy;                      # Ask for tidy cleanup
+       var $mInterfaceMessage;          # Which lang to call for PLURAL and GRAMMAR
+       var $mTargetLanguage;            # Overrides above setting with arbitrary language
+       var $mMaxIncludeSize;            # Maximum size of template expansions, in bytes
+       var $mMaxPPNodeCount;            # Maximum number of nodes touched by PPFrame::expand()
+       var $mMaxPPExpandDepth;          # Maximum recursion depth in PPFrame::expand()
+       var $mMaxTemplateDepth;          # Maximum recursion depth for templates within templates
+       var $mRemoveComments;            # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
+       var $mTemplateCallback;          # Callback for template fetching
+       var $mEnableLimitReport;         # Enable limit report in an HTML comment on output
+       var $mTimestamp;                 # Timestamp used for {{CURRENTDAY}} etc.
 
-       var $mUser;                      //!< Stored user object, just used to initialise the skin
+       var $mUser;                      # Stored user object, just used to initialise the skin
 
        function getUseTeX()                        { return $this->mUseTeX; }
        function getUseDynamicDates()               { return $this->mUseDynamicDates; }
@@ -97,7 +98,7 @@ class ParserOptions {
 
        /**
         * Get parser options
-        * @param $user User
+        * @static
         */
        static function newFromUser( $user ) {
                return new ParserOptions( $user );
@@ -108,9 +109,8 @@ class ParserOptions {
                global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
                global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
                global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth;
-
-               wfProfileIn( __METHOD__ );
-
+               $fname = 'ParserOptions::initialiseFromUser';
+               wfProfileIn( $fname );
                if ( !$userInput ) {
                        global $wgUser;
                        if ( isset( $wgUser ) ) {
@@ -144,7 +144,6 @@ class ParserOptions {
                $this->mRemoveComments = true;
                $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' );
                $this->mEnableLimitReport = false;
-
-               wfProfileOut( __METHOD__ );
+               wfProfileOut( $fname );
        }
 }
index d435e7d..f95e5a5 100644 (file)
@@ -36,9 +36,7 @@ class RefreshLinksJob extends Job {
                }
 
                wfProfileIn( __METHOD__.'-parse' );
-               $user = new User();
-               $options = new ParserOptions( $user );
-               $options->setInterfaceMessage( true );
+               $options = new ParserOptions;
                $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options, true, true, $revision->getId() );
                wfProfileOut( __METHOD__.'-parse' );
                wfProfileIn( __METHOD__.'-update' );
index 00840d4..6bfc2ab 100644 (file)
@@ -2334,13 +2334,11 @@ class User {
         * which will give them a chance to modify this key based on their own
         * settings.
         *
-        * @param $content Bool: wheter use the content language to generate the
-        *                 hash
         * @return string
         */
-       function getPageRenderingHash( $content = false ) {
+       function getPageRenderingHash() {
                global $wgContLang, $wgUseDynamicDates, $wgLang;
-               if( $this->mHash && !$content ){
+               if( $this->mHash ){
                        return $this->mHash;
                }
 
@@ -2353,11 +2351,7 @@ class User {
                        $confstr .= '!' . $this->getDatePreference();
                }
                $confstr .= '!' . ($this->getOption( 'numberheadings' ) ? '1' : '');
-               if( $content ){
-                       $confstr .= '!' . $wgContLang->getCode();
-               } else {
-                       $confstr .= '!' . $wgLang->getCode();
-               }
+               $confstr .= '!' . $wgLang->getCode();
                $confstr .= '!' . $this->getOption( 'thumbsize' );
                // add in language specific options, if any
                $extra = $wgContLang->getExtraHashOptions();