MediaWiki r35059 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r35058‎ | r35059 (on ViewVC)‎ | r35060 >
Date:21:33, 19 May 2008
Author:nicdumz
Status:old
Tags:
Comment:
#14094 When the expansion size is reached, the editor is not warned about it :
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
Modified paths:

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -561,6 +561,10 @@
562562 'recreate-deleted-warn',
563563 'expensive-parserfunction-warning',
564564 'expensive-parserfunction-category',
 565+ 'post-expand-template-inclusion-warning',
 566+ 'post-expand-template-inclusion-category',
 567+ 'post-expand-template-argument-warning',
 568+ 'post-expand-template-argument-category',
565569 ),
566570 'undo' => array(
567571 'undo-success',
Index: trunk/phase3/includes/ParserOutput.php
@@ -21,7 +21,7 @@
2222 $mNoGallery, # No gallery on category page? (__NOGALLERY__)
2323 $mHeadItems, # Items to put in the <head> section
2424 $mOutputHooks, # Hook tags as per $wgParserOutputHooks
25 - $mWarnings, # Warning text to be returned to the user. Wikitext formatted.
 25+ $mWarnings, # Warning text to be returned to the user. Wikitext formatted, in the key only
2626 $mSections, # Table of contents
2727 $mProperties; # Name/value pairs to be cached in the DB
2828
@@ -68,7 +68,7 @@
6969 function getNoGallery() { return $this->mNoGallery; }
7070 function getSubtitle() { return $this->mSubtitle; }
7171 function getOutputHooks() { return (array)$this->mOutputHooks; }
72 - function getWarnings() { return isset( $this->mWarnings ) ? $this->mWarnings : array(); }
 72+ function getWarnings() { return array_keys( $this->mWarnings ); }
7373
7474 function containsOldMagic() { return $this->mContainsOldMagic; }
7575 function setText( $text ) { return wfSetVar( $this->mText, $text ); }
@@ -82,7 +82,7 @@
8383 function addCategory( $c, $sort ) { $this->mCategories[$c] = $sort; }
8484 function addLanguageLink( $t ) { $this->mLanguageLinks[] = $t; }
8585 function addExternalLink( $url ) { $this->mExternalLinks[$url] = 1; }
86 - function addWarning( $s ) { $this->mWarnings[] = $s; }
 86+ function addWarning( $s ) { $this->mWarnings[$s] = 1; }
8787
8888 function addOutputHook( $hook, $data = false ) {
8989 $this->mOutputHooks[] = array( $hook, $data );
Index: trunk/phase3/includes/Parser.php
@@ -394,14 +394,7 @@
395395 }
396396 global $wgExpensiveParserFunctionLimit;
397397 if ( $this->mExpensiveFunctionCount > $wgExpensiveParserFunctionLimit ) {
398 - if ( is_callable( array( $this->mOutput, 'addWarning' ) ) ) {
399 - $warning = wfMsg( 'expensive-parserfunction-warning', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit );
400 - $this->mOutput->addWarning( $warning );
401 - $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( 'expensive-parserfunction-category' ) );
402 - if ( $cat ) {
403 - $this->mOutput->addCategory( $cat->getDBkey(), $this->getDefaultSort() );
404 - }
405 - }
 398+ $this->limitationWarn( 'expensive-parserfunction', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit );
406399 }
407400
408401 wfRunHooks( 'ParserAfterTidy', array( &$this, &$text ) );
@@ -2703,6 +2696,28 @@
27042697 }
27052698
27062699 /**
 2700+ * Warn the user when a parser limitation is reached
 2701+ * Will warn at most once the user per limitation type
 2702+ *
 2703+ * @param string $limitationType, should be one of :
 2704+ * 'expensive-parserfunction'
 2705+ * 'post-expand-template-argument'
 2706+ * 'post-expand-template-inclusion'
 2707+ * @params int $current, $max When an explicit limit has been
 2708+ * exceeded, provide the values (optional)
 2709+ */
 2710+ function limitationWarn( $limitationType, $current=null, $max=null) {
 2711+ $msgName = $limitationType . '-warning';
 2712+ //does no harm if $current and $max are present but are unnecessary for the message
 2713+ $warning = wfMsg( $msgName, $current, $max);
 2714+ $this->mOutput->addWarning( $warning );
 2715+ $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( $limitationType . '-category' ) );
 2716+ if ( $cat ) {
 2717+ $this->mOutput->addCategory( $cat->getDBkey(), $this->getDefaultSort() );
 2718+ }
 2719+ }
 2720+
 2721+ /**
27072722 * Return the text of a template, after recursively
27082723 * replacing any variables or templates within the template.
27092724 *
@@ -2988,6 +3003,7 @@
29893004 # Error, oversize inclusion
29903005 $text = "[[$originalTitle]]" .
29913006 $this->insertStripItem( '<!-- WARNING: template omitted, post-expand include size too large -->' );
 3007+ $this->limitationWarn( 'post-expand-template-inclusion' );
29923008 }
29933009
29943010 if ( $isLocalObj ) {
@@ -3186,6 +3202,7 @@
31873203 }
31883204 if ( !$this->incrementIncludeSize( 'arg', strlen( $text ) ) ) {
31893205 $error = '<!-- WARNING: argument omitted, expansion size too large -->';
 3206+ $this->limitationWarn( 'post-expand-template-argument' );
31903207 }
31913208
31923209 if ( $text === false && $object === false ) {
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1142,6 +1142,10 @@
11431143
11441144 It should have less than $2, there are now $1.',
11451145 'expensive-parserfunction-category' => 'Pages with too many expensive parser function calls',
 1146+'post-expand-template-inclusion-warning' => "Warning: Template include size is too large, some templates will not be included.",
 1147+'post-expand-template-inclusion-category' => "Pages where template include size is exceeded",
 1148+'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.",
 1149+'post-expand-template-argument-category' => "Pages containing omitted template arguments",
11461150
11471151 # "Undo" feature
11481152 '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: trunk/phase3/languages/messages/MessagesFr.php
@@ -812,6 +812,10 @@
813813
814814 Il devrait en avoir moins de $2 sur le nombre actuel $1.',
815815 'expensive-parserfunction-category' => 'Pages avec trop d’appels dispendieux de fonctions parseurs',
 816+'post-expand-template-inclusion-warning' => "Attention : Cette page contient trop d'inclusions de modèles. Certaines inclusions ne seront pas effectuées.",
 817+'post-expand-template-inclusion-category' => "Pages contenant trop d'inclusions de modèles",
 818+'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"
 819+'post-expand-template-argument-category' => "Pages contenant au moins un paramètre de modèle non évalué",
816820
817821 # "Undo" feature
818822 '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é.',

Status & tagging log

  • 15:27, 12 September 2011 Meno25 (talk | contribs) changed the status of r35059 [removed: ok added: old]