Adding 2 messages + 2 categories, similarly to "Warning: This page contains too many expensive parser function calls" to warn the user when template post include size (or template argument post include size) is too large
}
global $wgExpensiveParserFunctionLimit;
if ( $this->mExpensiveFunctionCount > $wgExpensiveParserFunctionLimit ) {
- if ( is_callable( array( $this->mOutput, 'addWarning' ) ) ) {
- $warning = wfMsg( 'expensive-parserfunction-warning', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit );
- $this->mOutput->addWarning( $warning );
- $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( 'expensive-parserfunction-category' ) );
- if ( $cat ) {
- $this->mOutput->addCategory( $cat->getDBkey(), $this->getDefaultSort() );
- }
- }
+ $this->limitationWarn( 'expensive-parserfunction', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit );
}
wfRunHooks( 'ParserAfterTidy', array( &$this, &$text ) );
return $assocArgs;
}
+ /**
+ * Warn the user when a parser limitation is reached
+ * Will warn at most once the user per limitation type
+ *
+ * @param string $limitationType, should be one of :
+ * 'expensive-parserfunction'
+ * 'post-expand-template-argument'
+ * 'post-expand-template-inclusion'
+ * @params int $current, $max When an explicit limit has been
+ * exceeded, provide the values (optional)
+ */
+ function limitationWarn( $limitationType, $current=null, $max=null) {
+ $msgName = $limitationType . '-warning';
+ //does no harm if $current and $max are present but are unnecessary for the message
+ $warning = wfMsg( $msgName, $current, $max);
+ $this->mOutput->addWarning( $warning );
+ $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( $limitationType . '-category' ) );
+ if ( $cat ) {
+ $this->mOutput->addCategory( $cat->getDBkey(), $this->getDefaultSort() );
+ }
+ }
+
/**
* Return the text of a template, after recursively
* replacing any variables or templates within the template.
# Error, oversize inclusion
$text = "[[$originalTitle]]" .
$this->insertStripItem( '<!-- WARNING: template omitted, post-expand include size too large -->' );
+ $this->limitationWarn( 'post-expand-template-inclusion' );
}
if ( $isLocalObj ) {
}
if ( !$this->incrementIncludeSize( 'arg', strlen( $text ) ) ) {
$error = '<!-- WARNING: argument omitted, expansion size too large -->';
+ $this->limitationWarn( 'post-expand-template-argument' );
}
if ( $text === false && $object === false ) {
$mNoGallery, # No gallery on category page? (__NOGALLERY__)
$mHeadItems, # Items to put in the <head> section
$mOutputHooks, # Hook tags as per $wgParserOutputHooks
- $mWarnings, # Warning text to be returned to the user. Wikitext formatted.
+ $mWarnings, # Warning text to be returned to the user. Wikitext formatted, in the key only
$mSections, # Table of contents
$mProperties; # Name/value pairs to be cached in the DB
function getNoGallery() { return $this->mNoGallery; }
function getSubtitle() { return $this->mSubtitle; }
function getOutputHooks() { return (array)$this->mOutputHooks; }
- function getWarnings() { return isset( $this->mWarnings ) ? $this->mWarnings : array(); }
+ function getWarnings() { return array_keys( $this->mWarnings ); }
function containsOldMagic() { return $this->mContainsOldMagic; }
function setText( $text ) { return wfSetVar( $this->mText, $text ); }
function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; }
function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }
function addExternalLink( $url ) { $this->mExternalLinks[$url] = 1; }
- function addWarning( $s ) { $this->mWarnings[] = $s; }
+ function addWarning( $s ) { $this->mWarnings[$s] = 1; }
function addOutputHook( $hook, $data = false ) {
$this->mOutputHooks[] = array( $hook, $data );
It should have less than $2, there are now $1.',
'expensive-parserfunction-category' => 'Pages with too many expensive parser function calls',
+'post-expand-template-inclusion-warning' => "Warning: Template include size is too large, some templates will not be included.",
+'post-expand-template-inclusion-category' => "Pages where template include size is exceeded",
+'post-expand-template-argument-warning' => "Warning: This page contains at least one template argument which has a too large expansion size. These arguments have been omitted.",
+'post-expand-template-argument-category' => "Pages containing omitted template arguments",
# "Undo" feature
'undo-success' => 'The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.',
Il devrait en avoir moins de $2 sur le nombre actuel $1.',
'expensive-parserfunction-category' => 'Pages avec trop d’appels dispendieux de fonctions parseurs',
+'post-expand-template-inclusion-warning' => "Attention : Cette page contient trop d'inclusions de modèles. Certaines inclusions ne seront pas effectuées.",
+'post-expand-template-inclusion-category' => "Pages contenant trop d'inclusions de modèles",
+'post-expand-template-argument-warning' => "Attention : Cette page contient au moins un paramètre de modèle dont l'inclusion est rendue impossible. Après extension, celui-ci aurait produit un résultat trop long, il n'a donc pas été inclut"
+'post-expand-template-argument-category' => "Pages contenant au moins un paramètre de modèle non évalué",
# "Undo" feature
'undo-success' => 'Cette modification va être défaite. Veuillez confirmer les changements (visibles en bas de cette page), puis sauvegarder si vous êtes d’accord. Merci de motiver l’annulation dans la boîte de résumé.',
'recreate-deleted-warn',
'expensive-parserfunction-warning',
'expensive-parserfunction-category',
+ 'post-expand-template-inclusion-warning',
+ 'post-expand-template-inclusion-category',
+ 'post-expand-template-argument-warning',
+ 'post-expand-template-argument-category',
),
'undo' => array(
'undo-success',