Yurik has uploaded a new change for review.

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


Change subject: Fixed two bugs in zero config editor
......................................................................

Fixed two bugs in zero config editor

* Providing non-boolean values as boolean were corrupting data
* Zero config edit preview were causing errors on errors

Change-Id: I5190d7204929614055279c61d1bb471819db03f6
---
M includes/CarrierConfig.php
M includes/ConfigPageHooks.php
M includes/ZeroConfigContent.php
3 files changed, 19 insertions(+), 21 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroRatedMobileAccess 
refs/changes/50/68850/1

diff --git a/includes/CarrierConfig.php b/includes/CarrierConfig.php
index a2bd341..161b26c 100644
--- a/includes/CarrierConfig.php
+++ b/includes/CarrierConfig.php
@@ -53,19 +53,17 @@
        }
 
        /**
-        * Returns null if no error, or the Message object
-        * @return Message|null
+        * Returns null if no error, or the rendering of error messages
+        * @return string|null
         */
        public function getErrorMessage() {
-               return $this->errorMessage;
-       }
-
-       /**
-        * Get a dictionary of field names and their error message
-        * @return array
-        */
-       public function getErrors() {
-               return $this->errors;
+               $err = $this->errorMessage;
+               if ( $err !== null ) {
+                       foreach ( $this->errors as $f => $e ) {
+                               $err .= wfMessage( 'zeroconfig-field_error', 
$f, $e );
+                       }
+               }
+               return $err;
        }
 
        /**
@@ -120,10 +118,10 @@
                $this->originalJson = $json;
 
                $validateBool = function( $v ) {
-                       return is_bool( $v ) ? null : array( $v, wfMessage( 
'zeroconfig-opt_bool' ) );
+                       return is_bool( $v ) ? null : wfMessage( 
'zeroconfig-opt_bool' );
                };
                $validateStr = function( $v ) {
-                       return is_string( $v ) ? null : array( $v, wfMessage( 
'zeroconfig-opt_string' ) );
+                       return is_string( $v ) ? null : wfMessage( 
'zeroconfig-opt_string' );
                };
 
                // Optional comment
diff --git a/includes/ConfigPageHooks.php b/includes/ConfigPageHooks.php
index 7aaba25..249a133 100644
--- a/includes/ConfigPageHooks.php
+++ b/includes/ConfigPageHooks.php
@@ -64,11 +64,7 @@
                if ( $editor->getTitle()->inNamespace( NS_ZERO ) ) {
                        $config = new CarrierConfig( $text );
                        if ( $config->isError() ) {
-                               $err = $config->getErrorMessage();
-                               foreach ( $config->getErrors() as $f => $e ) {
-                                       $err .= wfMessage( 
'zeroconfig-field_error', $f, $e );
-                               }
-                               $error = $err;
+                               $error = $config->getErrorMessage();
                        }
                }
                wfProfileOut( __METHOD__ );
diff --git a/includes/ZeroConfigContent.php b/includes/ZeroConfigContent.php
index c6a1975..e959767 100644
--- a/includes/ZeroConfigContent.php
+++ b/includes/ZeroConfigContent.php
@@ -61,9 +61,13 @@
         * @return string HTML representation.
         */
        function getHtml() {
-               $conf = $this->config->getData();
-               return
-                       self::objectTable( $conf ) . '<br />' . 
$this->renderBanners( $conf );
+               $config = $this->config;
+               if ( $config->isError() ) {
+                       return $config->getErrorMessage();
+               } else {
+                       $data = $config->getData();
+                       return self::objectTable( $data ) . '<br />' . 
$this->renderBanners( $data );
+               }
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5190d7204929614055279c61d1bb471819db03f6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroRatedMobileAccess
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to