From: Brion Vibber Date: Wed, 11 Jun 2008 02:51:30 +0000 (+0000) Subject: Revert r36093 (bug 14404). X-Git-Tag: 1.31.0-rc.0~47052 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=36ad2b73c4ab1eb5f2ed0c849f4d556e288d2fa7;p=lhc%2Fweb%2Fwiklou.git Revert r36093 (bug 14404). 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. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 9215660c82..517faee147 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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. diff --git a/includes/Article.php b/includes/Article.php index 0fa49e41f6..d709f62730 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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( '#REDIRECT ' . ''.$link.'' ); - + } 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__ ); diff --git a/includes/CoreParserFunctions.php b/includes/CoreParserFunctions.php index 60dce1929a..d9072e9310 100644 --- a/includes/CoreParserFunctions.php +++ b/includes/CoreParserFunctions.php @@ -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 ); } diff --git a/includes/ParserCache.php b/includes/ParserCache.php index 72d4c60e26..bf11da2eeb 100644 --- a/includes/ParserCache.php +++ b/includes/ParserCache.php @@ -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 ) { diff --git a/includes/ParserOptions.php b/includes/ParserOptions.php index 4fd7ca289b..330ec446cb 100644 --- a/includes/ParserOptions.php +++ b/includes/ParserOptions.php @@ -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 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 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 ); } } diff --git a/includes/RefreshLinksJob.php b/includes/RefreshLinksJob.php index d435e7d630..f95e5a505e 100644 --- a/includes/RefreshLinksJob.php +++ b/includes/RefreshLinksJob.php @@ -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' ); diff --git a/includes/User.php b/includes/User.php index 00840d43d8..6bfc2abc42 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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();