http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70434
Revision: 70434 Author: platonides Date: 2010-08-03 22:32:09 +0000 (Tue, 03 Aug 2010) Log Message: ----------- http://www.mediawiki.org/wiki/User:Catrope/Stub_threshold shows us people setting it to insanely large values trying to disable it. r70433 addressed the UI. Here we proxy its access via a new method getStubThreshold() that disables it if a page of such size cannot be created (by an user), so we can serve them parser cached articles again. Modified Paths: -------------- trunk/phase3/includes/Article.php trunk/phase3/includes/Linker.php trunk/phase3/includes/User.php trunk/phase3/includes/parser/LinkHolderArray.php Modified: trunk/phase3/includes/Article.php =================================================================== --- trunk/phase3/includes/Article.php 2010-08-03 22:13:16 UTC (rev 70433) +++ trunk/phase3/includes/Article.php 2010-08-03 22:32:09 UTC (rev 70434) @@ -891,7 +891,7 @@ # Should the parser cache be used? $useParserCache = $this->useParserCache( $oldid ); wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); - if ( $wgUser->getOption( 'stubthreshold' ) ) { + if ( $wgUser->getStubThreshold() ) { wfIncrStats( 'pcache_miss_stub' ); } @@ -1450,7 +1450,7 @@ global $wgUser, $wgEnableParserCache; return $wgEnableParserCache - && intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 + && $wgUser->getStubThreshold() == 0 && $this->exists() && empty( $oldid ) && !$this->mTitle->isCssOrJsPage() @@ -4589,13 +4589,13 @@ // Should the parser cache be used? $useParserCache = $wgEnableParserCache && - intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 && + $wgUser->getStubThreshold() == 0 && $this->exists() && $oldid === null; wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); - if ( $wgUser->getOption( 'stubthreshold' ) ) { + if ( $wgUser->getStubThreshold() ) { wfIncrStats( 'pcache_miss_stub' ); } Modified: trunk/phase3/includes/Linker.php =================================================================== --- trunk/phase3/includes/Linker.php 2010-08-03 22:13:16 UTC (rev 70433) +++ trunk/phase3/includes/Linker.php 2010-08-03 22:32:09 UTC (rev 70434) @@ -267,7 +267,7 @@ } if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387) - $colour = $this->getLinkColour( $target, $wgUser->getOption( 'stubthreshold' ) ); + $colour = $this->getLinkColour( $target, $wgUser->getStubThreshold() ); if ( $colour !== '' ) { $classes[] = $colour; # mw-redirect or stub } @@ -337,7 +337,7 @@ global $wgUser; wfDeprecated( __METHOD__ ); - $threshold = intval( $wgUser->getOption( 'stubthreshold' ) ); + $threshold = $wgUser->getStubThreshold(); $colour = ( $size < $threshold ) ? 'stub' : ''; // FIXME: replace deprecated makeColouredLinkObj by link() return $this->makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix ); Modified: trunk/phase3/includes/User.php =================================================================== --- trunk/phase3/includes/User.php 2010-08-03 22:13:16 UTC (rev 70433) +++ trunk/phase3/includes/User.php 2010-08-03 22:32:09 UTC (rev 70434) @@ -2079,6 +2079,20 @@ } /** + * Get the user preferred stub threshold + */ + function getStubThreshold() { + global $wgMaxArticleSize; # Maximum article size, in Kb + $threshold = intval( $this->getOption( 'stubthreshold' ) ); + if ( $threshold > $wgMaxArticleSize * 1024 ) { + # If they have set an impossible value, disable the preference + # so we can use the parser cache again. + $threshold = 0; + } + return $threshold; + } + + /** * Get the permissions this user has. * @return \type{\arrayof{\string}} Array of permission names */ @@ -2686,10 +2700,11 @@ } // stubthreshold is only included below for completeness, - // it will always be 0 when this function is called by parsercache. + // since it disables the parser cache, its value will always + // be 0 when this function is called by parsercache. $confstr = $this->getOption( 'math' ); - $confstr .= '!' . $this->getOption( 'stubthreshold' ); + $confstr .= '!' . $this->getStubThreshold(); if ( $wgUseDynamicDates ) { $confstr .= '!' . $this->getDatePreference(); } @@ -2700,6 +2715,9 @@ $extra = $wgContLang->getExtraHashOptions(); $confstr .= $extra; + // Since the skin could be overloading link(), it should be + // included here but in practice, none of our skins do that. + $confstr .= $wgRenderHashAppend; // Give a chance for extensions to modify the hash, if they have Modified: trunk/phase3/includes/parser/LinkHolderArray.php =================================================================== --- trunk/phase3/includes/parser/LinkHolderArray.php 2010-08-03 22:13:16 UTC (rev 70433) +++ trunk/phase3/includes/parser/LinkHolderArray.php 2010-08-03 22:32:09 UTC (rev 70434) @@ -99,7 +99,7 @@ function getStubThreshold() { global $wgUser; if ( !isset( $this->stubThreshold ) ) { - $this->stubThreshold = $wgUser->getOption('stubthreshold'); + $this->stubThreshold = $wgUser->getStubThreshold(); } return $this->stubThreshold; } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs