Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/58878


Change subject: Remove usage of ValueParsers Result interface
......................................................................

Remove usage of ValueParsers Result interface

This needs https://gerrit.wikimedia.org/r/#/c/58867/

Change-Id: I8b985acaf48ca731b826a2bc3d72209e0443360e
---
M includes/ParamProcessor/Param.php
1 file changed, 13 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Validator 
refs/changes/78/58878/1

diff --git a/includes/ParamProcessor/Param.php 
b/includes/ParamProcessor/Param.php
index 592840a..a1f46e8 100644
--- a/includes/ParamProcessor/Param.php
+++ b/includes/ParamProcessor/Param.php
@@ -3,6 +3,7 @@
 namespace ParamProcessor;
 
 use MWException;
+use ValueParsers\ParseException;
 use ValueParsers\ValueParser;
 
 /**
@@ -299,24 +300,21 @@
         * @return array|bool
         */
        protected function parseAndValidateValue( ValueParser $parser, $value ) 
{
-               $parsingResult = $parser->parse( $value );
-
-               if ( $parsingResult->isValid() ) {
-                       $value = $parsingResult->getValue();
-
-                       if ( $value instanceof \DataValues\DataValue ) {
-                               $value = $value->getValue();
-                       }
-
-                       $this->validateValue( $value );
-
-                       return array( $value );
+               try {
+                       $value = $parser->parse( $value );
                }
-               else {
-                       $this->registerProcessingError( 
$parsingResult->getError()->getText() );
+               catch ( ParseException $parseException ) {
+                       $this->registerProcessingError( 
$parseException->getMessage() );
+                       return false;
                }
 
-               return false;
+               if ( $value instanceof \DataValues\DataValue ) {
+                       $value = $value->getValue();
+               }
+
+               $this->validateValue( $value );
+
+               return array( $value );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/58878
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8b985acaf48ca731b826a2bc3d72209e0443360e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Validator
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to