r103176 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103175‎ | r103176 | r103177 >
Date:14:40, 15 November 2011
Author:danwe
Status:deferred
Tags:
Comment:
$egLoopsDisabledFunctions bug from previous submit solved, parser functions which need Variables extension will be disabled if it is not available.
Modified paths:
  • /trunk/extensions/Loops/Loops.php (modified) (history)
  • /trunk/extensions/Loops/RELEASE-NOTES (modified) (history)

Diff [purge]

Index: trunk/extensions/Loops/Loops.php
@@ -77,7 +77,17 @@
7878 * @since 0.4
7979 */
8080 public static function init( Parser &$parser ) {
81 -
 81+
 82+ if( ! class_exists( 'ExtVariables' ) ) {
 83+ /*
 84+ * If Variables extension not defined, we can't use certain functions.
 85+ * Make sure they are disabled:
 86+ */
 87+ global $egLoopsDisabledFunctions;
 88+ $disabledFunctions = array( 'loop', 'forargs', 'fornumargs' );
 89+ $egLoopsDisabledFunctions = array_merge( $egLoopsDisabledFunctions, $disabledFunctions );
 90+ }
 91+
8292 /*
8393 * store for loops count per parser object. This will solve several bugs related to
8494 * 'ParserClearState' hook resetting the count early in combination with certain
@@ -97,7 +107,7 @@
98108 global $egLoopsDisabledFunctions;
99109
100110 // don't register parser function if disabled by configuration:
101 - if( ! in_array( $name, $egLoopsDisabledFunctions ) ) {
 111+ if( in_array( $name, $egLoopsDisabledFunctions ) ) {
102112 return;
103113 }
104114
@@ -242,8 +252,8 @@
243253 */
244254 protected static function perform_forargs( Parser &$parser, PPFrame $frame, array $funcArgs, array $templateArgs, $prefix = '' ) {
245255 // if not called within template instance:
246 - if( !( $frame instanceof PPTemplateFrame_DOM ) ) {
247 - return array( 'found' => false );
 256+ if( !( $frame->isTemplate() ) ) {
 257+ return '';
248258 }
249259
250260 // name of the variable to store the argument name:
Index: trunk/extensions/Loops/RELEASE-NOTES
@@ -6,6 +6,7 @@
77 counter, for example including an special page in wikitext. This has been solved now.
88 - Compatbility to Variables Version 2.0.
99 - Configuration variable '$egLoopsDisabledFunctions' to disable certain Loops parser functions.
 10+ - If 'Variables' extension is not active, '#loop', '#forargs' and '#fornumargs' will be disabled.
1011 - Language file clean-up.
1112 - Internal structure changed, ExtLoops now works as a static class.
1213 - '#fornumargs' parameter 1 can be empty to make it more consistent with other Loop parser

Status & tagging log