r74886 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74885‎ | r74886 | r74887 >
Date:09:28, 17 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.4.1 - follow up to r74885
Modified paths:
  • /trunk/extensions/Validator/INSTALL (modified) (history)
  • /trunk/extensions/Validator/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/Validator/Validator.php (modified) (history)
  • /trunk/extensions/Validator/includes/CriterionValidationResult.php (modified) (history)
  • /trunk/extensions/Validator/includes/Parameter.php (modified) (history)
  • /trunk/extensions/Validator/includes/ValidationError.php (modified) (history)
  • /trunk/extensions/Validator/includes/Validator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/INSTALL
@@ -1,4 +1,4 @@
2 -[[Validator 0.4]]
 2+[[Validator 0.4.1]]
33
44 Once you have downloaded the code, place the 'Validator' directory within
55 your MediaWiki 'extensions' directory. Then add the following code to your
Index: trunk/extensions/Validator/RELEASE-NOTES
@@ -12,15 +12,15 @@
1313 ==== New features ====
1414
1515 * Added ParserHook class that allows for out-of-the-box parser function and tag extension creation
16 - with full Validator support.
 16+: with full Validator support.
1717
18 -* Added listerrors parser hook that allows you to list all validation errors that occured at the point it's rendered.
 18+* Added listerrors parser hook that allows you to list all validation errors that occurred at the point it's rendered.
1919
2020 * Added support for conditional parameter adding.
2121
2222 ==== Refactoring ====
2323
24 -Bascially everything got rewritten...
 24+Basically everything got rewritten...
2525
2626 * Added Parameter and ListParameter classes to replace parameter definitions in array form.
2727
Index: trunk/extensions/Validator/includes/ValidationError.php
@@ -36,7 +36,7 @@
3737 *
3838 * @var array
3939 */
40 - public $tags;
 40+ protected $tags;
4141
4242 /**
4343 * Where the error occured.
@@ -61,6 +61,18 @@
6262 }
6363
6464 /**
 65+ * Adds one or more tags.
 66+ *
 67+ * @since 0.4.1
 68+ *
 69+ * @param mixed $criteria string or array of string
 70+ */
 71+ public function addTags() {
 72+ $args = func_get_args();
 73+ $this->tags += is_array( $args[0] ) ? $args[0] : $args;
 74+ }
 75+
 76+ /**
6577 * Returns the error message describing the error.
6678 *
6779 * @since 0.4
@@ -98,6 +110,8 @@
99111 *
100112 * @since 0.4
101113 *
 114+ * @param integer $severity
 115+ *
102116 * @return boolean
103117 */
104118 public function hasSeverity( $severity ) {
@@ -105,6 +119,30 @@
106120 }
107121
108122 /**
 123+ * Returns if the error has a certain tag.
 124+ *
 125+ * @since 0.4.1
 126+ *
 127+ * @param string $tag
 128+ *
 129+ * @return boolean
 130+ */
 131+ public function hasTag( $tag ) {
 132+ return in_array( $tag, $this->tags );
 133+ }
 134+
 135+ /**
 136+ * Returns the tags.
 137+ *
 138+ * @since 0.4.1
 139+ *
 140+ * @return array
 141+ */
 142+ public function getTags() {
 143+ return $this->tags;
 144+ }
 145+
 146+ /**
109147 * Returns the action associated with the errors severity.
110148 *
111149 * @since 0.4
Index: trunk/extensions/Validator/includes/CriterionValidationResult.php
@@ -22,7 +22,7 @@
2323 /**
2424 * @since 0.4
2525 *
26 - * @var unknown_type
 26+ * @var array of string
2727 */
2828 protected $invalidItems = array();
2929
@@ -32,7 +32,7 @@
3333 * @since 0.4
3434 */
3535 public function __construct() {
36 -
 36+
3737 }
3838
3939 /**
Index: trunk/extensions/Validator/includes/Parameter.php
@@ -326,7 +326,7 @@
327327 */
328328 public function addAliases() {
329329 $args = func_get_args();
330 - $this->aliases = array_merge( $this->aliases, is_array( $args[0] ) ? $args[0] : $args );
 330+ $this->aliases += is_array( $args[0] ) ? $args[0] : $args;
331331 }
332332
333333 /**
@@ -338,7 +338,7 @@
339339 */
340340 public function addCriteria() {
341341 $args = func_get_args();
342 - $this->criteria = array_merge( $this->criteria, is_array( $args[0] ) ? $args[0] : $args );
 342+ $this->criteria += is_array( $args[0] ) ? $args[0] : $args;
343343 }
344344
345345 /**
@@ -351,7 +351,7 @@
352352 */
353353 public function addDependencies() {
354354 $args = func_get_args();
355 - $this->dependencies = array_merge( $this->dependencies, is_array( $args[0] ) ? $args[0] : $args );
 355+ $this->dependencies += is_array( $args[0] ) ? $args[0] : $args;
356356 }
357357
358358 /**
@@ -363,7 +363,7 @@
364364 */
365365 public function addManipulations( $manipulations ) {
366366 $args = func_get_args();
367 - $this->manipulations = array_merge( $this->manipulations, is_array( $args[0] ) ? $args[0] : $args );
 367+ $this->manipulations += is_array( $args[0] ) ? $args[0] : $args;
368368 }
369369
370370 /**
@@ -523,7 +523,10 @@
524524 * @param CriterionValidationResult $validationResult
525525 */
526526 protected function handleValidationError( CriterionValidationResult $validationResult ) {
527 - $this->errors = array_merge( $this->errors, $validationResult->getErrors() );
 527+ foreach ( $validationResult->getErrors() as $error ) {
 528+ $error->addTags( $this->getName() );
 529+ $this->errors[] = $error;
 530+ }
528531 }
529532
530533 /**
Index: trunk/extensions/Validator/includes/Validator.php
@@ -229,7 +229,8 @@
230230 // These are unrecognized parameters, as they where not used by any parameter definition.
231231 foreach ( $this->rawParameters as $paramName => $paramValue ) {
232232 $this->registerNewError(
233 - wfMsgExt( 'validator_error_unknown_argument', 'parsemag', $paramName )
 233+ wfMsgExt( 'validator_error_unknown_argument', 'parsemag', $paramName ),
 234+ $paramName
234235 );
235236 }
236237 }
@@ -252,7 +253,7 @@
253254 if ( !$setUservalue && $parameter->isRequired() ) {
254255 $this->registerNewError(
255256 wfMsgExt( 'validator_error_required_missing', 'parsemag', $paramName ),
256 - array(),
 257+ array( $paramName, 'missing' ),
257258 ValidationError::SEVERITY_FATAL
258259 );
259260 break;
Index: trunk/extensions/Validator/Validator.php
@@ -24,7 +24,7 @@
2525 die( 'Not an entry point.' );
2626 }
2727
28 -define( 'Validator_VERSION', '0.4' );
 28+define( 'Validator_VERSION', '0.4.1 alpha' );
2929
3030 // Register the internationalization file.
3131 $wgExtensionMessagesFiles['Validator'] = dirname( __FILE__ ) . '/Validator.i18n.php';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74885Changes for 0.7.1 - improvements to layer validationjeroendedauw09:27, 17 October 2010

Status & tagging log