Index: maintenance/language/messages.inc =================================================================== --- maintenance/language/messages.inc (révision 34600) +++ maintenance/language/messages.inc (copie de travail) @@ -561,6 +561,10 @@ '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', Index: includes/ParserOutput.php =================================================================== --- includes/ParserOutput.php (révision 34600) +++ includes/ParserOutput.php (copie de travail) @@ -21,7 +21,7 @@ $mNoGallery, # No gallery on category page? (__NOGALLERY__) $mHeadItems, # Items to put in the 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 @@ -82,7 +82,7 @@ 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 ); Index: includes/Parser.php =================================================================== --- includes/Parser.php (révision 34600) +++ includes/Parser.php (copie de travail) @@ -394,14 +394,7 @@ } 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 ) ); @@ -2703,6 +2696,35 @@ } /** + * 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) { + # Why were we checking this ? + # TODO: documentation please + if ( is_callable( array( $this->mOutput, 'addWarning' ) ) ) { + $msgName = $limitationType . '-warning'; + if ( is_null( $current ) || is_null( $max ) ) { + $warning = wfMsg( $msgName ); + } else { + $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. * @@ -2988,6 +3010,7 @@ # Error, oversize inclusion $text = "[[$originalTitle]]" . $this->insertStripItem( '' ); + $this->limitationWarn( 'post-expand-template-inclusion' ); } if ( $isLocalObj ) { @@ -3181,6 +3204,7 @@ } if ( !$this->incrementIncludeSize( 'arg', strlen( $text ) ) ) { $error = ''; + $this->limitationWarn( 'post-expand-template-argument' ); } if ( $text === false && $object === false ) { Index: includes/EditPage.php =================================================================== --- includes/EditPage.php (révision 34600) +++ includes/EditPage.php (copie de travail) @@ -1596,7 +1596,7 @@ $this->mPreviewTemplates[] = Title::makeTitle($ns, $dbk); if ( count( $parserOutput->getWarnings() ) ) { - $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() ); + $note .= "\n\n" . implode( "\n\n", array_keys( $parserOutput->getWarnings() ) ); } } Index: languages/messages/MessagesEn.php =================================================================== --- languages/messages/MessagesEn.php (révision 34600) +++ languages/messages/MessagesEn.php (copie de travail) @@ -1141,6 +1141,10 @@ 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.', Index: languages/messages/MessagesFr.php =================================================================== --- languages/messages/MessagesFr.php (révision 34600) +++ languages/messages/MessagesFr.php (copie de travail) @@ -812,6 +812,10 @@ 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é.',