r36185 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36184‎ | r36185 | r36186 >
Date:02:51, 11 June 2008
Author:brion
Status:old
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/ParserCache.php (modified) (history)
  • /trunk/phase3/includes/ParserOptions.php (modified) (history)
  • /trunk/phase3/includes/RefreshLinksJob.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -2334,13 +2334,11 @@
23352335 * which will give them a chance to modify this key based on their own
23362336 * settings.
23372337 *
2338 - * @param $content Bool: wheter use the content language to generate the
2339 - * hash
23402338 * @return string
23412339 */
2342 - function getPageRenderingHash( $content = false ) {
 2340+ function getPageRenderingHash() {
23432341 global $wgContLang, $wgUseDynamicDates, $wgLang;
2344 - if( $this->mHash && !$content ){
 2342+ if( $this->mHash ){
23452343 return $this->mHash;
23462344 }
23472345
@@ -2353,11 +2351,7 @@
23542352 $confstr .= '!' . $this->getDatePreference();
23552353 }
23562354 $confstr .= '!' . ($this->getOption( 'numberheadings' ) ? '1' : '');
2357 - if( $content ){
2358 - $confstr .= '!' . $wgContLang->getCode();
2359 - } else {
2360 - $confstr .= '!' . $wgLang->getCode();
2361 - }
 2355+ $confstr .= '!' . $wgLang->getCode();
23622356 $confstr .= '!' . $this->getOption( 'thumbsize' );
23632357 // add in language specific options, if any
23642358 $extra = $wgContLang->getExtraHashOptions();
Index: trunk/phase3/includes/Article.php
@@ -541,9 +541,9 @@
542542 */
543543 function isRedirect( $text = false ) {
544544 if ( $text === false ) {
545 - if ( $this->mDataLoaded )
 545+ if ( $this->mDataLoaded )
546546 return $this->mIsRedirect;
547 -
 547+
548548 // Apparently loadPageData was never called
549549 $this->loadContent();
550550 $titleObj = Title::newFromRedirect( $this->fetchContent() );
@@ -922,14 +922,14 @@
923923 $this->viewUpdates();
924924 wfProfileOut( __METHOD__ );
925925 }
926 -
 926+
927927 protected function viewRedirect( $target, $overwriteSubtitle = true, $forceKnown = false ) {
928928 global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
929 -
 929+
930930 # Display redirect
931931 $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
932932 $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png';
933 -
 933+
934934 if( $overwriteSubtitle ) {
935935 $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) );
936936 }
@@ -941,7 +941,7 @@
942942
943943 $wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
944944 '<span class="redirectText">'.$link.'</span>' );
945 -
 945+
946946 }
947947
948948 function addTrackbacks() {
@@ -1449,7 +1449,7 @@
14501450
14511451 # Update page
14521452 $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision );
1453 -
 1453+
14541454 wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, $baseRevId) );
14551455
14561456 if( !$ok ) {
@@ -1521,7 +1521,7 @@
15221522
15231523 # Update the page record with revision data
15241524 $this->updateRevisionOn( $dbw, $revision, 0 );
1525 -
 1525+
15261526 wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
15271527
15281528 if( !( $flags & EDIT_SUPPRESS_RC ) ) {
@@ -1881,7 +1881,7 @@
18821882 'page_id' => $id
18831883 ), 'Article::protect'
18841884 );
1885 -
 1885+
18861886 wfRunHooks( 'NewRevisionFromEditComplete', array($this, $nullRevision, false) );
18871887 wfRunHooks( 'ArticleProtectComplete', array( &$this, &$wgUser, $limit, $reason ) );
18881888
@@ -2242,7 +2242,7 @@
22432243 function doDelete( $reason, $suppress = false ) {
22442244 global $wgOut, $wgUser;
22452245 wfDebug( __METHOD__."\n" );
2246 -
 2246+
22472247 $id = $this->getId();
22482248
22492249 if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason))) {
@@ -2514,14 +2514,14 @@
25152515 if( empty( $summary ) ){
25162516 $summary = wfMsgForContent( 'revertpage' );
25172517 }
2518 -
 2518+
25192519 # Allow the custom summary to use the same args as the default message
25202520 $args = array(
25212521 $target->getUserText(), $from, $s->rev_id,
25222522 $wgLang->timeanddate(wfTimestamp(TS_MW, $s->rev_timestamp), true),
25232523 $current->getId(), $wgLang->timeanddate($current->getTimestamp())
25242524 );
2525 - $summary = wfMsgReplaceArgs( $summary, $args );
 2525+ $summary = wfMsgReplaceArgs( $summary, $args );
25262526
25272527 # Save
25282528 $flags = EDIT_UPDATE;
@@ -2609,7 +2609,7 @@
26102610 . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
26112611 $wgOut->addHtml( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
26122612 $wgOut->returnToMain( false, $this->mTitle );
2613 -
 2613+
26142614 if( !$wgRequest->getBool( 'hidediff', false ) ) {
26152615 $de = new DifferenceEngine( $this->mTitle, $current->getId(), 'next', false, true );
26162616 $de->showDiff( '', '' );
@@ -2640,7 +2640,7 @@
26412641
26422642 /**
26432643 * Prepare text which is about to be saved.
2644 - * Returns a stdclass with source, pst, output and user members
 2644+ * Returns a stdclass with source, pst and output members
26452645 */
26462646 function prepareTextForEdit( $text, $revid=null ) {
26472647 if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) {
@@ -2652,14 +2652,11 @@
26532653 $edit->revid = $revid;
26542654 $edit->newText = $text;
26552655 $edit->pst = $this->preSaveTransform( $text );
2656 - $user = new User();
2657 - $options = new ParserOptions( $user );
 2656+ $options = new ParserOptions;
26582657 $options->setTidy( true );
2659 - $options->setInterfaceMessage( true ); // @bug 14404
26602658 $options->enableLimitReport();
26612659 $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $options, true, true, $revid );
26622660 $edit->oldText = $this->getContent();
2663 - $edit->user = $user;
26642661 $this->mPreparedEdit = $edit;
26652662 return $edit;
26662663 }
@@ -2695,7 +2692,7 @@
26962693 # Save it to the parser cache
26972694 if ( $wgEnableParserCache ) {
26982695 $parserCache = ParserCache::singleton();
2699 - $parserCache->save( $editInfo->output, $this, $editInfo->user, /*content*/true );
 2696+ $parserCache->save( $editInfo->output, $this, $wgUser );
27002697 }
27012698
27022699 # Update the links tables
@@ -2984,7 +2981,7 @@
29852982 $revision->insertOn( $dbw );
29862983 $this->updateRevisionOn( $dbw, $revision );
29872984 $dbw->commit();
2988 -
 2985+
29892986 wfRunHooks( 'NewRevisionFromEditComplete', array($this, $revision, false) );
29902987
29912988 wfProfileOut( __METHOD__ );
Index: trunk/phase3/includes/RefreshLinksJob.php
@@ -36,9 +36,7 @@
3737 }
3838
3939 wfProfileIn( __METHOD__.'-parse' );
40 - $user = new User();
41 - $options = new ParserOptions( $user );
42 - $options->setInterfaceMessage( true );
 40+ $options = new ParserOptions;
4341 $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options, true, true, $revision->getId() );
4442 wfProfileOut( __METHOD__.'-parse' );
4543 wfProfileIn( __METHOD__.'-update' );
Index: trunk/phase3/includes/ParserOptions.php
@@ -5,31 +5,32 @@
66 * @todo document
77 * @ingroup Parser
88 */
9 -class ParserOptions {
 9+class ParserOptions
 10+{
1011 # All variables are supposed to be private in theory, although in practise this is not the case.
11 - var $mUseTeX; //!< Use texvc to expand <math> tags
12 - var $mUseDynamicDates; //!< Use DateFormatter to format dates
13 - var $mInterwikiMagic; //!< Interlanguage links are removed and returned in an array
14 - var $mAllowExternalImages; //!< Allow external images inline
15 - var $mAllowExternalImagesFrom; //!< If not, any exception?
16 - var $mSkin; //!< Reference to the preferred skin
17 - var $mDateFormat; //!< Date format index
18 - var $mEditSection; //!< Create "edit section" links
19 - var $mNumberHeadings; //!< Automatically number headings
20 - var $mAllowSpecialInclusion; //!< Allow inclusion of special pages
21 - var $mTidy; //!< Ask for tidy cleanup
22 - var $mInterfaceMessage; //!< Which lang to call for PLURAL and GRAMMAR
23 - var $mTargetLanguage; //!< Overrides above setting with arbitrary language
24 - var $mMaxIncludeSize; //!< Maximum size of template expansions, in bytes
25 - var $mMaxPPNodeCount; //!< Maximum number of nodes touched by PPFrame::expand()
26 - var $mMaxPPExpandDepth; //!< Maximum recursion depth in PPFrame::expand()
27 - var $mMaxTemplateDepth; //!< Maximum recursion depth for templates within templates
28 - var $mRemoveComments; //!< Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
29 - var $mTemplateCallback; //!< Callback for template fetching
30 - var $mEnableLimitReport; //!< Enable limit report in an HTML comment on output
31 - var $mTimestamp; //!< Timestamp used for {{CURRENTDAY}} etc.
 12+ var $mUseTeX; # Use texvc to expand <math> tags
 13+ var $mUseDynamicDates; # Use DateFormatter to format dates
 14+ var $mInterwikiMagic; # Interlanguage links are removed and returned in an array
 15+ var $mAllowExternalImages; # Allow external images inline
 16+ var $mAllowExternalImagesFrom; # If not, any exception?
 17+ var $mSkin; # Reference to the preferred skin
 18+ var $mDateFormat; # Date format index
 19+ var $mEditSection; # Create "edit section" links
 20+ var $mNumberHeadings; # Automatically number headings
 21+ var $mAllowSpecialInclusion; # Allow inclusion of special pages
 22+ var $mTidy; # Ask for tidy cleanup
 23+ var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR
 24+ var $mTargetLanguage; # Overrides above setting with arbitrary language
 25+ var $mMaxIncludeSize; # Maximum size of template expansions, in bytes
 26+ var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand()
 27+ var $mMaxPPExpandDepth; # Maximum recursion depth in PPFrame::expand()
 28+ var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates
 29+ var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
 30+ var $mTemplateCallback; # Callback for template fetching
 31+ var $mEnableLimitReport; # Enable limit report in an HTML comment on output
 32+ var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
3233
33 - var $mUser; //!< Stored user object, just used to initialise the skin
 34+ var $mUser; # Stored user object, just used to initialise the skin
3435
3536 function getUseTeX() { return $this->mUseTeX; }
3637 function getUseDynamicDates() { return $this->mUseDynamicDates; }
@@ -97,7 +98,7 @@
9899
99100 /**
100101 * Get parser options
101 - * @param $user User
 102+ * @static
102103 */
103104 static function newFromUser( $user ) {
104105 return new ParserOptions( $user );
@@ -108,9 +109,8 @@
109110 global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
110111 global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
111112 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth;
112 -
113 - wfProfileIn( __METHOD__ );
114 -
 113+ $fname = 'ParserOptions::initialiseFromUser';
 114+ wfProfileIn( $fname );
115115 if ( !$userInput ) {
116116 global $wgUser;
117117 if ( isset( $wgUser ) ) {
@@ -144,7 +144,6 @@
145145 $this->mRemoveComments = true;
146146 $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' );
147147 $this->mEnableLimitReport = false;
148 -
149 - wfProfileOut( __METHOD__ );
 148+ wfProfileOut( $fname );
150149 }
151150 }
Index: trunk/phase3/includes/CoreParserFunctions.php
@@ -56,15 +56,7 @@
5757 static function intFunction( $parser, $part1 = '' /*, ... */ ) {
5858 if ( strval( $part1 ) !== '' ) {
5959 $args = array_slice( func_get_args(), 2 );
60 - $opts = array();
61 - if( ( $langObj = $parser->mOptions->getTargetLanguage() ) !== null ){
62 - $opts['language'] = $langObj->getCode();
63 - } else if( $parser->mOptions->getInterfaceMessage() ) {
64 - $opts[] = 'content';
65 - }
66 - $msg = call_user_func_array( 'wfMsgExt',
67 - array_merge( array( $part1, $opts ), $args ) );
68 - return $parser->replaceVariables( $msg );
 60+ return wfMsgReal( $part1, $args, true );
6961 } else {
7062 return array( 'found' => false );
7163 }
Index: trunk/phase3/includes/ParserCache.php
@@ -26,9 +26,9 @@
2727 $this->mMemc =& $memCached;
2828 }
2929
30 - function getKey( &$article, &$user, $content = false ) {
 30+ function getKey( &$article, &$user ) {
3131 global $action;
32 - $hash = $user->getPageRenderingHash( $content );
 32+ $hash = $user->getPageRenderingHash();
3333 if( !$article->mTitle->quickUserCan( 'edit' ) ) {
3434 // section edit links are suppressed even if the user has them on
3535 $edit = '!edit=0';
@@ -86,9 +86,9 @@
8787 return $value;
8888 }
8989
90 - function save( $parserOutput, &$article, &$user, $content = false ){
 90+ function save( $parserOutput, &$article, &$user ){
9191 global $wgParserCacheExpireTime;
92 - $key = $this->getKey( $article, $user, $content );
 92+ $key = $this->getKey( $article, $user );
9393
9494 if( $parserOutput->getCacheTime() != -1 ) {
9595
Index: trunk/phase3/RELEASE-NOTES
@@ -351,8 +351,6 @@
352352 * (bug 14401) Fix Safari access key tooltips for Windows and >3.1 Mac versions
353353 * (bug 14432) Fix notice regression in Special:Newpages feed mode
354354 * (bug 11951) EditPage::getEditToolbar() is now static.
355 -* (bug 14404) Use of {{int:...}} to generate links no longer breaks links table
356 - if user has a custom interface language
357355 * (bug 14392) Fix regression breaking table prefix in installer
358356 * (bug 11084) $wgDBprefix replacement for updater SQL will now work for
359357 extension tables using uppercase letters or digits in their names.

Follow-up revisions

RevisionCommit summaryAuthorDate
r89706Reinstate r79122 (fix for bug 14404), reverting r83868. The real bug seem to ...platonides22:28, 7 June 2011
r97206Follow up r89706, building up on r97091....platonides21:09, 15 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r36093Some tweaks to the {{int:...}} parser function:...ialex17:57, 9 June 2008

Status & tagging log