Jeroen De Dauw has submitted this change and it was merged.

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(-)

Approvals:
  Jeroen De Dauw: Verified; Looks good to me, approved



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: merged
Gerrit-Change-Id: I8b985acaf48ca731b826a2bc3d72209e0443360e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Validator
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com>
Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com>
Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>

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

Reply via email to