r72720 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72719‎ | r72720 | r72721 >
Date:14:07, 10 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.4 - work on validation error handling
Modified paths:
  • /trunk/extensions/Validator/includes/Validator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/Validator.php
@@ -188,7 +188,7 @@
189189
190190 }
191191 else { // If the parameter is not found in the list of allowed ones, add an item to the $this->mErrors array.
192 - $this->registerError(
 192+ $this->registerNewError(
193193 wfMsgExt(
194194 'validator_error_unknown_argument',
195195 'parsemag',
@@ -209,16 +209,27 @@
210210 * @param mixed $tags string or array
211211 * @param integer $severity
212212 */
213 - protected function registerError( $message, $tags = array(), $severity = ValidatorError::SEVERITY_NORMAL ) {
214 - $error = new ValidatorError(
215 - $message,
216 - $severity,
217 - $this->element,
218 - (array)$tags
 213+ protected function registerNewError( $message, $tags = array(), $severity = ValidatorError::SEVERITY_NORMAL ) {
 214+ $this->registerError(
 215+ new ValidatorError(
 216+ $message,
 217+ $severity,
 218+ $this->element,
 219+ (array)$tags
 220+ )
219221 );
220 -
 222+ }
 223+
 224+ /**
 225+ * Registers an error.
 226+ *
 227+ * @since 0.4
 228+ *
 229+ * @param ValidationError $error
 230+ */
 231+ protected function registerError( ValidatorError $error ) {
221232 $this->errors[] = $error;
222 - ValidatorErrorHandler::addError( $error );
 233+ ValidatorErrorHandler::addError( $error );
223234 }
224235
225236 /**
@@ -279,7 +290,9 @@
280291 $parameter = $this->parameters[$paramName];
281292
282293 if ( !$parameter->validate() ) {
283 - $this->errors = array_merge( $this->errors, $parameter->getErrors() );
 294+ foreach ( $parameter->getErrors() as $error ) {
 295+ $this->registerError( $error );
 296+ }
284297 }
285298 }
286299 }

Status & tagging log