r103194 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103193‎ | r103194 | r103195 >
Date:17:25, 15 November 2011
Author:danwe
Status:deferred
Tags:
Comment:
config var $egLoopsDisabledFunctions renamed to $egLoopsEnabledFunctions, white-list instead of black-list.
Modified paths:
  • /trunk/extensions/Loops/Loops.php (modified) (history)
  • /trunk/extensions/Loops/Loops_Settings.php (modified) (history)
  • /trunk/extensions/Loops/RELEASE-NOTES (modified) (history)

Diff [purge]

Index: trunk/extensions/Loops/Loops.php
@@ -84,9 +84,9 @@
8585 * If Variables extension not defined, we can't use certain functions.
8686 * Make sure they are disabled:
8787 */
88 - global $egLoopsDisabledFunctions;
 88+ global $egLoopsEnabledFunctions;
8989 $disabledFunctions = array( 'loop', 'forargs', 'fornumargs' );
90 - $egLoopsDisabledFunctions = array_merge( $egLoopsDisabledFunctions, $disabledFunctions );
 90+ $egLoopsEnabledFunctions = array_diff( $egLoopsEnabledFunctions, $disabledFunctions );
9191 }
9292
9393 /*
@@ -105,10 +105,10 @@
106106 return true;
107107 }
108108 private static function initFunction( Parser &$parser, $name ) {
109 - global $egLoopsDisabledFunctions;
 109+ global $egLoopsEnabledFunctions;
110110
111111 // don't register parser function if disabled by configuration:
112 - if( in_array( $name, $egLoopsDisabledFunctions ) ) {
 112+ if( ! in_array( $name, $egLoopsEnabledFunctions ) ) {
113113 return;
114114 }
115115
@@ -384,4 +384,5 @@
385385
386386 return true;
387387 }
 388+
388389 }
Index: trunk/extensions/Loops/Loops_Settings.php
@@ -17,13 +17,15 @@
1818 */
1919
2020 /**
21 - * Allows to define which functionalities provided by 'Loops' should be disabled for the wiki.
 21+ * Allows to define which functionalities provided by 'Loops' should be enabled for the wiki.
 22+ * If extension 'Variables' is not installed, '#loop', '#forargs' and '#fornumargs' will be
 23+ * disabled automatically.
2224 *
2325 * @example
24 - * # disable 'fornumargs' and 'forargs' parser functions:
25 - * $egLoopsDisabledFunctions = array( 'fornumargs', 'forargs' );
 26+ * # enable '#while' and '#dowhile' parser functions only:
 27+ * egLoopsEnabledFunctions = array( 'while', 'dowhile' );
2628 *
2729 * @since 0.4
2830 * @var array
2931 */
30 -$egLoopsDisabledFunctions = array();
 32+$egLoopsEnabledFunctions = array( 'while', 'dowhile', 'loop', 'forargs', 'fornumargs' );
Index: trunk/extensions/Loops/RELEASE-NOTES
@@ -3,17 +3,18 @@
44
55 * (trunk) -- Version 0.4 alpha by Daniel Werner
66 - The loops count now counts per parser instance. Before there were several hacks to reset the
7 - counter, for example including an special page in wikitext. This has been solved now.
 7+ counter, for example a special-page inclusion. This has been solved now.
 8+ - 'Loops' is working with MW 1.18+ now. Should be compatible down to MW 1.12.
89 - Compatbility to Variables Version 2.0.
9 - - Configuration variable '$egLoopsDisabledFunctions' to disable certain Loops parser functions.
 10+ - Configuration variable '$egLoopsEnabledFunctions' to enable certain Loops parser functions only.
1011 - If 'Variables' extension is not active, '#loop', '#forargs' and '#fornumargs' will be disabled.
1112 - If loop limit exceeded, the error message will be part of the output wrapped inside a 'div'
1213 with error class so it can be caught by '#iferror'.
13 - - Language file clean-up.
14 - - Internal structure changed, ExtLoops now works as a static class.
1514 - '#fornumargs' parameter 1 can be empty to make it more consistent with other Loop parser
1615 functions. E.g. '{{#fornumargs: | keyVarName | valVarName | code }}' istead of
1716 '{{#fornumargs: keyVarName | valVarName | code }}' (which still works as well).
 17+ - Language file clean-up.
 18+ - Internal structure changed, ExtLoops now works as a static class.
1819
1920 * November 15, 2011 -- Version 0.3.2 by Daniel Werner
2021 - Bug solved where '#loop' didn't create variables with name or starting index '0'.

Status & tagging log