]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16289 - actually unpack xmlrpc errors rather than just whinge the payload is...
authormjollnir_ <mjollnir_>
Tue, 2 Sep 2008 14:11:53 +0000 (14:11 +0000)
committermjollnir_ <mjollnir_>
Tue, 2 Sep 2008 14:11:53 +0000 (14:11 +0000)
mnet/xmlrpc/client.php
mnet/xmlrpc/xmlparser.php

index f2a983efb771ec9d2e11d019110332a262fb7cc8..d6d5936814cf73ef6b7fa08d0aaf396abfcba6e0 100644 (file)
@@ -249,8 +249,9 @@ class mnet_xmlrpc_client {
             }
 
         } else {
-
-            if (! empty($crypt_parser->error)) {
+            if (! empty($crypt_parser->remoteerror)) {
+                $this->error[] = '4: remote server error: ' . $crypt_parser->remoteerror;
+            } else if (! empty($crypt_parser->error)) {
                 $crypt_parser_error = $crypt_parser->error[0];
 
                 $message = '3:XML Parse error in payload: '.$crypt_parser_error['string']."\n";
index 1d74381d25546a5d74ab1e343395a65770193a46..e62743d4a9099fd59057ebb00054fd20ff21e698 100644 (file)
@@ -43,6 +43,8 @@ class mnet_encxml_parser {
         $this->payload_encrypted = false;
         $this->cipher            = array();
         $this->error             = array();
+        $this->remoteerror       = null;
+        $this->errorstarted      = false;
         return true;
     }
 
@@ -113,6 +115,10 @@ class mnet_encxml_parser {
             }
         }
 
+        if (!empty($this->remoteerror)) {
+            return false;
+        }
+
         if (count($this->cipher) > 0) {
             $this->cipher = array_values($this->cipher);
             $this->payload_encrypted = true;
@@ -166,6 +172,8 @@ class mnet_encxml_parser {
                 $this->cipher[$this->tag_number] = '';
                 $handler = 'parse_cipher';
                 break;
+            case 'FAULT':
+                $handler = 'parse_fault';
             default:
                 break;
         }
@@ -264,7 +272,27 @@ class mnet_encxml_parser {
      * @return  bool            True
      */
     function discard_data($parser, $data) {
-        // Not interested
+        if (!$this->errorstarted) {
+            // Not interested
+            return true;
+        }
+        $data = trim($data);
+        if (isset($this->errorstarted->faultstringstarted) && !empty($data)) {
+            $this->remoteerror .= ', message: ' . $data;
+        } else if (isset($this->errorstarted->faultcodestarted)) {
+            $this->remoteerror = 'code: ' . $data;
+            unset($this->errorstarted->faultcodestarted);
+        } else if ($data == 'faultCode') {
+            $this->errorstarted->faultcodestarted = true;
+        } else if ($data == 'faultString') {
+            $this->errorstarted->faultstringstarted = true;
+        }
+        return true;
+
+    }
+
+    function parse_fault($parser, $data) {
+        $this->errorstarted = new StdClass;
         return true;
     }