r103174 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103173‎ | r103174 | r103175 >
Date:14:25, 15 November 2011
Author:danwe
Status:deferred (Comments)
Tags:
Comment:
settings file and $egLoopsDisabledFunctions configuration variable introduced
Modified paths:
  • /trunk/extensions/Loops/Loops.php (modified) (history)
  • /trunk/extensions/Loops/Loops_Settings.php (added) (history)
  • /trunk/extensions/Loops/RELEASE-NOTES (modified) (history)

Diff [purge]

Index: trunk/extensions/Loops/Loops.php
@@ -35,7 +35,10 @@
3636 $wgHooks['ParserFirstCallInit'][] = 'ExtLoops::init';
3737 $wgHooks['ParserClearState' ][] = 'ExtLoops::onParserClearState';
3838
 39+// Include the settings file:
 40+require_once ExtLoops::getDir() . '/Loops_Settings.php';
3941
 42+
4043 /**
4144 * Class representing extension 'Loops', containing all parser functions and other
4245 * extension logic stuff.
@@ -90,9 +93,16 @@
9194
9295 return true;
9396 }
94 - private static function initFunction( Parser &$parser, $name ) {
 97+ private static function initFunction( Parser &$parser, $name ) {
 98+ global $egLoopsDisabledFunctions;
 99+
 100+ // don't register parser function if disabled by configuration:
 101+ if( ! in_array( $name, $egLoopsDisabledFunctions ) ) {
 102+ return;
 103+ }
 104+
95105 $functionCallback = array( __CLASS__, 'pfObj_' . $name );
96 - $parser->setFunctionHook( $name, $functionCallback, SFH_OBJECT_ARGS );
 106+ $parser->setFunctionHook( $name, $functionCallback, SFH_OBJECT_ARGS );
97107 }
98108
99109
Index: trunk/extensions/Loops/Loops_Settings.php
@@ -0,0 +1,29 @@
 2+<?php
 3+
 4+/**
 5+ * File defining the settings for the 'Loops' extension.
 6+ * More info can be found at http://www.mediawiki.org/wiki/Extension:Loops#Configuration
 7+ *
 8+ * NOTICE:
 9+ * =======
 10+ * Changing one of these settings can be done by copying and placing
 11+ * it in LocalSettings.php, AFTER the inclusion of 'Loops'.
 12+ *
 13+ * @file Loops_Settings.php
 14+ * @ingroup Loops
 15+ * @since 0.4
 16+ *
 17+ * @author Daniel Werner
 18+ */
 19+
 20+/**
 21+ * Allows to define which functionalities provided by 'Loops' should be disabled for the wiki.
 22+ *
 23+ * @example
 24+ * # disable 'fornumargs' and 'forargs' parser functions:
 25+ * $egLoopsDisabledFunctions = array( 'fornumargs', 'forargs' );
 26+ *
 27+ * @since 0.4
 28+ * @var array
 29+ */
 30+$egLoopsDisabledFunctions = array();
Property changes on: trunk/extensions/Loops/Loops_Settings.php
___________________________________________________________________
Added: svn:eol-style
131 + native
Index: trunk/extensions/Loops/RELEASE-NOTES
@@ -5,6 +5,7 @@
66 - The loops count now counts per parser instance. Before there were several hacks to reset the
77 counter, for example including an special page in wikitext. This has been solved now.
88 - Compatbility to Variables Version 2.0.
 9+ - Configuration variable '$egLoopsDisabledFunctions' to disable certain Loops parser functions.
910 - Language file clean-up.
1011 - Internal structure changed, ExtLoops now works as a static class.
1112 - '#fornumargs' parameter 1 can be empty to make it more consistent with other Loop parser

Comments

#Comment by Nikerabbit (talk | contribs)   15:26, 15 November 2011

Just wondering whether whitelist makes more sense. Now newly introduced functions get enabled by default.

#Comment by Danwe (talk | contribs)   17:32, 15 November 2011

Probably doesn't make much difference since Site Admins always should check release notes and decide what new functions to disable/enable, but your suggested white-list would at least make sure no new unwanted feature slips through unintendedly somehow - now new wanted features unintendedly won't be enabled perhaps, but it seems like the lesser evil. Implemented in r103194

Status & tagging log