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.
# 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' );
}
global $wgUser, $wgEnableParserCache;
return $wgEnableParserCache
- && intval( $wgUser->getOption( 'stubthreshold' ) ) == 0
+ && $wgUser->getStubThreshold() == 0
&& $this->exists()
&& empty( $oldid )
&& !$this->mTitle->isCssOrJsPage()
// 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' );
}
}
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
}
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 );
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
}
// 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();
}
$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
function getStubThreshold() {
global $wgUser;
if ( !isset( $this->stubThreshold ) ) {
- $this->stubThreshold = $wgUser->getOption('stubthreshold');
+ $this->stubThreshold = $wgUser->getStubThreshold();
}
return $this->stubThreshold;
}