r74513 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74512‎ | r74513 | r74514 >
Date:13:47, 8 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.4 - fixed small issue and improved listerrors parser hook
Modified paths:
  • /trunk/extensions/Validator/includes/Parameter.php (modified) (history)
  • /trunk/extensions/Validator/includes/ParserHook.php (modified) (history)
  • /trunk/extensions/Validator/includes/ValidationError.php (modified) (history)
  • /trunk/extensions/Validator/includes/ValidationErrorHandler.php (modified) (history)
  • /trunk/extensions/Validator/includes/Validator.php (modified) (history)
  • /trunk/extensions/Validator/includes/parserHooks/Validator_ListErrors.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/ValidationErrorHandler.php
@@ -28,7 +28,7 @@
2929 * @param integer $severity
3030 */
3131 public static function addError( ValidationError $error ) {
32 - self::$errors[$error->element ? $error->element : 'unknown'][] = $error;
 32+ self::$errors[$error->getElement()][] = $error;
3333 }
3434
3535 /**
Index: trunk/extensions/Validator/includes/ValidationError.php
@@ -72,6 +72,17 @@
7373 }
7474
7575 /**
 76+ * Returns the element this error occured at, or 'unknown' when i's unknown.
 77+ *
 78+ * @since 0.4
 79+ *
 80+ * @return string
 81+ */
 82+ public function getElement() {
 83+ return $this->element === false ? 'unknown' : $this->element;
 84+ }
 85+
 86+ /**
7687 * Returns the severity of the error.
7788 *
7889 * @since 0.4
Index: trunk/extensions/Validator/includes/parserHooks/Validator_ListErrors.php
@@ -128,7 +128,7 @@
129129 if ( count( $errors ) == 0 ) {
130130 return '';
131131 }
132 -
 132+
133133 $elements = array_keys( $errors );
134134 natcasesort( $elements );
135135
Index: trunk/extensions/Validator/includes/ParserHook.php
@@ -226,7 +226,8 @@
227227 public function validateAndRender( array $arguments, $type ) {
228228 global $egValidatorErrorLevel;
229229
230 - $this->validator = new Validator( $this->getName() );
 230+ $names = $this->getNames();
 231+ $this->validator = new Validator( $names[0] );
231232
232233 if ( $type === self::TYPE_FUNCTION ) {
233234 $this->validator->setFunctionParams( $arguments, $this->getParameterInfo( $type ), $this->getDefaultParameters( $type ) );
Index: trunk/extensions/Validator/includes/Parameter.php
@@ -358,8 +358,8 @@
359359 }
360360
361361 /**
 362+ * Sets and cleans the original value and name.
362363 *
363 - *
364364 * @since 0.4
365365 *
366366 * @param string $paramName
Index: trunk/extensions/Validator/includes/Validator.php
@@ -188,6 +188,7 @@
189189 * @param ValidationError $error
190190 */
191191 protected function registerError( ValidationError $error ) {
 192+ $error->element = $this->element;
192193 $this->errors[] = $error;
193194 ValidationErrorHandler::addError( $error );
194195 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r74514Follow up to r74513jeroendedauw13:57, 8 October 2010

Status & tagging log