http://www.mediawiki.org/wiki/User:Catrope/Stub_threshold shows us people setting...
authorPlatonides <platonides@users.mediawiki.org>
Tue, 3 Aug 2010 22:32:09 +0000 (22:32 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Tue, 3 Aug 2010 22:32:09 +0000 (22:32 +0000)
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.

includes/Article.php
includes/Linker.php
includes/User.php
includes/parser/LinkHolderArray.php

index 51b1270..3812658 100644 (file)
@@ -891,7 +891,7 @@ class Article {
                # 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 @@ class Article {
                global $wgUser, $wgEnableParserCache;
 
                return $wgEnableParserCache
-                       && intval( $wgUser->getOption( 'stubthreshold' ) ) == 0
+                       && $wgUser->getStubThreshold() == 0
                        && $this->exists()
                        && empty( $oldid )
                        && !$this->mTitle->isCssOrJsPage()
@@ -4589,13 +4589,13 @@ class Article {
 
                // 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' );
                }
 
index db9202a..a8d9c8b 100644 (file)
@@ -267,7 +267,7 @@ class Linker {
                        }
 
                        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 @@ class Linker {
                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 );
index 0ed1716..d376da2 100644 (file)
@@ -2078,6 +2078,20 @@ class User {
                return $this->mDatePreference;
        }
 
+       /**
+        * 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 @@ class User {
                }
 
                // 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 @@ class User {
                $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
index b1732f0..5379d17 100644 (file)
@@ -99,7 +99,7 @@ class LinkHolderArray {
        function getStubThreshold() {
                global $wgUser;
                if ( !isset( $this->stubThreshold ) ) {
-                       $this->stubThreshold = $wgUser->getOption('stubthreshold');
+                       $this->stubThreshold = $wgUser->getStubThreshold();
                }
                return $this->stubThreshold;
        }