Index: trunk/phase3/includes/User.php |
— | — | @@ -2079,6 +2079,20 @@ |
2080 | 2080 | } |
2081 | 2081 | |
2082 | 2082 | /** |
| 2083 | + * Get the user preferred stub threshold |
| 2084 | + */ |
| 2085 | + function getStubThreshold() { |
| 2086 | + global $wgMaxArticleSize; # Maximum article size, in Kb |
| 2087 | + $threshold = intval( $this->getOption( 'stubthreshold' ) ); |
| 2088 | + if ( $threshold > $wgMaxArticleSize * 1024 ) { |
| 2089 | + # If they have set an impossible value, disable the preference |
| 2090 | + # so we can use the parser cache again. |
| 2091 | + $threshold = 0; |
| 2092 | + } |
| 2093 | + return $threshold; |
| 2094 | + } |
| 2095 | + |
| 2096 | + /** |
2083 | 2097 | * Get the permissions this user has. |
2084 | 2098 | * @return \type{\arrayof{\string}} Array of permission names |
2085 | 2099 | */ |
— | — | @@ -2686,10 +2700,11 @@ |
2687 | 2701 | } |
2688 | 2702 | |
2689 | 2703 | // stubthreshold is only included below for completeness, |
2690 | | - // it will always be 0 when this function is called by parsercache. |
| 2704 | + // since it disables the parser cache, its value will always |
| 2705 | + // be 0 when this function is called by parsercache. |
2691 | 2706 | |
2692 | 2707 | $confstr = $this->getOption( 'math' ); |
2693 | | - $confstr .= '!' . $this->getOption( 'stubthreshold' ); |
| 2708 | + $confstr .= '!' . $this->getStubThreshold(); |
2694 | 2709 | if ( $wgUseDynamicDates ) { |
2695 | 2710 | $confstr .= '!' . $this->getDatePreference(); |
2696 | 2711 | } |
— | — | @@ -2700,6 +2715,9 @@ |
2701 | 2716 | $extra = $wgContLang->getExtraHashOptions(); |
2702 | 2717 | $confstr .= $extra; |
2703 | 2718 | |
| 2719 | + // Since the skin could be overloading link(), it should be |
| 2720 | + // included here but in practice, none of our skins do that. |
| 2721 | + |
2704 | 2722 | $confstr .= $wgRenderHashAppend; |
2705 | 2723 | |
2706 | 2724 | // Give a chance for extensions to modify the hash, if they have |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -891,7 +891,7 @@ |
892 | 892 | # Should the parser cache be used? |
893 | 893 | $useParserCache = $this->useParserCache( $oldid ); |
894 | 894 | wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
895 | | - if ( $wgUser->getOption( 'stubthreshold' ) ) { |
| 895 | + if ( $wgUser->getStubThreshold() ) { |
896 | 896 | wfIncrStats( 'pcache_miss_stub' ); |
897 | 897 | } |
898 | 898 | |
— | — | @@ -1450,7 +1450,7 @@ |
1451 | 1451 | global $wgUser, $wgEnableParserCache; |
1452 | 1452 | |
1453 | 1453 | return $wgEnableParserCache |
1454 | | - && intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 |
| 1454 | + && $wgUser->getStubThreshold() == 0 |
1455 | 1455 | && $this->exists() |
1456 | 1456 | && empty( $oldid ) |
1457 | 1457 | && !$this->mTitle->isCssOrJsPage() |
— | — | @@ -4589,13 +4589,13 @@ |
4590 | 4590 | |
4591 | 4591 | // Should the parser cache be used? |
4592 | 4592 | $useParserCache = $wgEnableParserCache && |
4593 | | - intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 && |
| 4593 | + $wgUser->getStubThreshold() == 0 && |
4594 | 4594 | $this->exists() && |
4595 | 4595 | $oldid === null; |
4596 | 4596 | |
4597 | 4597 | wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
4598 | 4598 | |
4599 | | - if ( $wgUser->getOption( 'stubthreshold' ) ) { |
| 4599 | + if ( $wgUser->getStubThreshold() ) { |
4600 | 4600 | wfIncrStats( 'pcache_miss_stub' ); |
4601 | 4601 | } |
4602 | 4602 | |
Index: trunk/phase3/includes/parser/LinkHolderArray.php |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | function getStubThreshold() { |
101 | 101 | global $wgUser; |
102 | 102 | if ( !isset( $this->stubThreshold ) ) { |
103 | | - $this->stubThreshold = $wgUser->getOption('stubthreshold'); |
| 103 | + $this->stubThreshold = $wgUser->getStubThreshold(); |
104 | 104 | } |
105 | 105 | return $this->stubThreshold; |
106 | 106 | } |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -267,7 +267,7 @@ |
268 | 268 | } |
269 | 269 | |
270 | 270 | if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387) |
271 | | - $colour = $this->getLinkColour( $target, $wgUser->getOption( 'stubthreshold' ) ); |
| 271 | + $colour = $this->getLinkColour( $target, $wgUser->getStubThreshold() ); |
272 | 272 | if ( $colour !== '' ) { |
273 | 273 | $classes[] = $colour; # mw-redirect or stub |
274 | 274 | } |
— | — | @@ -337,7 +337,7 @@ |
338 | 338 | global $wgUser; |
339 | 339 | wfDeprecated( __METHOD__ ); |
340 | 340 | |
341 | | - $threshold = intval( $wgUser->getOption( 'stubthreshold' ) ); |
| 341 | + $threshold = $wgUser->getStubThreshold(); |
342 | 342 | $colour = ( $size < $threshold ) ? 'stub' : ''; |
343 | 343 | // FIXME: replace deprecated makeColouredLinkObj by link() |
344 | 344 | return $this->makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix ); |