r77575 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77574‎ | r77575 | r77576 >
Date:12:39, 2 December 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added option to not handle unknown params as invalid to facilitate use of Validator when only caring about a subset of the provided parameters
Modified paths:
  • /trunk/extensions/Validator/Validator.php (modified) (history)
  • /trunk/extensions/Validator/includes/Validator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/Validator.php
@@ -61,6 +61,16 @@
6262 */
6363 protected $element;
6464
 65+ /**
 66+ * Indicates if unknown parameters should be seen as invalid.
 67+ * If this value is false, they will simply be ignored.
 68+ *
 69+ * @since 0.4.3
 70+ *
 71+ * @var boolean
 72+ */
 73+ protected $unknownInvalid;
 74+
6575 /**
6676 * Constructor.
6777 *
@@ -68,8 +78,9 @@
6979 *
7080 * @since 0.4
7181 */
72 - public function __construct( $element = '' ) {
 82+ public function __construct( $element = '', $unknownInvalid = true ) {
7383 $this->element = $element;
 84+ $this->unknownInvalid = $unknownInvalid;
7485 }
7586
7687 /**
@@ -224,7 +235,7 @@
225236 public function validateParameters() {
226237 $this->doParamProcessing();
227238
228 - if ( !$this->hasfatalError() ) {
 239+ if ( !$this->hasFatalError() && $this->unknownInvalid ) {
229240 // Loop over the remaining raw parameters.
230241 // These are unrecognized parameters, as they where not used by any parameter definition.
231242 foreach ( $this->rawParameters as $paramName => $paramValue ) {
Index: trunk/extensions/Validator/Validator.php
@@ -24,7 +24,7 @@
2525 die( 'Not an entry point.' );
2626 }
2727
28 -define( 'Validator_VERSION', '0.4.2' );
 28+define( 'Validator_VERSION', '0.4.3 alpha' );
2929
3030 // Register the internationalization file.
3131 $wgExtensionMessagesFiles['Validator'] = dirname( __FILE__ ) . '/Validator.i18n.php';

Status & tagging log