Issues

ZF-9387: Zend_XmlRpc_Client throws "Bad login/pass combination" exception when executing call 2 times in a row

Description

The following code has been working with 1.9.3, but stopped working after installing 1.10.2 after migrating straight from 1.9.3 to 1.10.2:

$blogId = new Zend_XmlRpc_Value_Integer($blogId);
$titleParams = array($blogId, $username, $password, $numberOfPostTitles);
client = new Zend_XmlRpc_Client($uri);
$titles = $client->call("mt.getRecentPostTitles", $titleParams);
// filter out titles with certain keywords, application internal method
$titles = $this->filterTitlesByKeyword($titles, $keyword);
$posts = array();
foreach($titles as $title){
    $postId = $title["postid"];
    $params = array($postId, $username, $password);
    $post = $client->call("metaWeblog.getPost", $params);
    if("publish" === $post["post_status"]){
        $posts[] = $post;
    }
}

The first call is properly executed and 10 post titles are returned. Upon the first subsequent call, the following exception is thrown by Zend_XmlRpc_Client (line 370): Zend_XmlRpc_Client_FaultException: Bad login/pass combination.

In an attempt to locate the issue, a dump was made of the request object from within Zend_XmlRpc_Client. Using version 1.9.3, the dump looks as follows:

object(Zend_XmlRpc_Request)#341 (7) {
  ["_encoding:protected"] => string(5) "UTF-8"
  ["_method:protected"] => string(22) "system.methodSignature"
  ["_xml:protected"] => NULL
  ["_params:protected"] => array(1) {
    [0] => string(18) "metaWeblog.getPost"
  }
  ["_fault:protected"] => NULL
  ["_types:protected"] => array(1) {
    [0] => string(6) "string"
  }
  ["_xmlRpcParams:protected"] => array(1) {
    [0] => array(2) {
      ["value"] => string(18) "metaWeblog.getPost"
      ["type"] => string(6) "string"
    }
  }
}

object(Zend_XmlRpc_Request)#345 (7) {
  ["_encoding:protected"] => string(5) "UTF-8"
  ["_method:protected"] => string(18) "metaWeblog.getPost"
  ["_xml:protected"] => NULL
  ["_params:protected"] => array(3) {
    [0] => string(3) "317"
    [1] => object(Zend_XmlRpc_Value_String)#353 (4) {
      ["_value:protected"] => string(5) "username"
      ["_type:protected"] => string(6) "string"
      ["_as_xml:protected"] => string(38) "username
"
      ["_as_dom:protected"] => object(DOMElement)#346 (0) {
      }
    }
    [2] => object(Zend_XmlRpc_Value_String)#352 (4) {
      ["_value:protected"] => string(13) "password"
      ["_type:protected"] => string(6) "string"
      ["_as_xml:protected"] => string(46) "password
"
      ["_as_dom:protected"] => object(DOMElement)#338 (0) {
      }
    }
  }
  ["_fault:protected"] => NULL
  ["_types:protected"] => array(3) {
    [0] => string(6) "string"
    [1] => string(6) "string"
    [2] => string(6) "string"
  }
  ["_xmlRpcParams:protected"] => array(3) {
    [0] => array(2) {
      ["value"] => string(3) "317"
      ["type"] => string(6) "string"
    }
    [1] => array(2) {
      ["value"] => object(Zend_XmlRpc_Value_String)#353 (4) {
        ["_value:protected"] => string(5) "username"
        ["_type:protected"] => string(6) "string"
        ["_as_xml:protected"] => string(38) "username
"
        ["_as_dom:protected"] => object(DOMElement)#346 (0) {
        }
      }
      ["type"] => string(6) "string"
    }
    [2] => array(2) {
      ["value"] => object(Zend_XmlRpc_Value_String)#352 (4) {
        ["_value:protected"] => string(13) "password"
        ["_type:protected"] => string(6) "string"
        ["_as_xml:protected"] => string(46) "password
"
        ["_as_dom:protected"] => object(DOMElement)#338 (0) {
        }
      }
      ["type"] => string(6) "string"
    }
  }
}

Using version 1.10.2, the dump of the request object within Zend_XmlRpc_Client looks as follows:

object(Zend_XmlRpc_Request)#343 (7) {
  ["_encoding:protected"] => string(5) "UTF-8"
  ["_method:protected"] => string(22) "system.methodSignature"
  ["_xml:protected"] => NULL
  ["_params:protected"] => array(1) {
    [0] => string(18) "metaWeblog.getPost"
  }
  ["_fault:protected"] => NULL
  ["_types:protected"] => array(1) {
    [0] => string(6) "string"
  }
  ["_xmlRpcParams:protected"] => array(1) {
    [0] => array(2) {
      ["value"] => string(18) "metaWeblog.getPost"
      ["type"] => string(6) "string"
    }
  }
}

object(Zend_XmlRpc_Request)#341 (7) {
  ["_encoding:protected"] => string(5) "UTF-8"
  ["_method:protected"] => string(18) "metaWeblog.getPost"
  ["_xml:protected"] => NULL
  ["_params:protected"] => array(3) {
    [0] => string(3) "317"
    [1] => object(Zend_XmlRpc_Value_String)#353 (3) {
      ["_value:protected"] => string(5) "username"
      ["_type:protected"] => string(6) "string"
      ["_xml:protected"] => string(153) "mt.getRecentPostTitles1
int>username"
    }
    [2] => object(Zend_XmlRpc_Value_String)#352 (3) {
      ["_value:protected"] => string(13) "password"
      ["_type:protected"] => string(6) "string"
      ["_xml:protected"] => string(213) "mt.getRecentPostTitles1
int>usernamepassword"
    }
  }
  ["_fault:protected"] => NULL
  ["_types:protected"] => array(3) {
    [0] => string(6) "string"
    [1] => string(6) "string"
    [2] => string(6) "string"
  }
  ["_xmlRpcParams:protected"] => array(3) {
    [0] => array(2) {
      ["value"] => string(3) "317"
      ["type"] => string(6) "string"
    }
    [1] => array(2) {
      ["value"] => object(Zend_XmlRpc_Value_String)#353 (3) {
        ["_value:protected"] => string(5) "username"
        ["_type:protected"] => string(6) "string"
        ["_xml:protected"] => string(153) "mt.getRecentPostTitles1
username"
      }
      ["type"] => string(6) "string"
    }
    [2] => array(2) {
      ["value"] => object(Zend_XmlRpc_Value_String)#352 (3) {
        ["_value:protected"] => string(13) "password"
        ["_type:protected"] => string(6) "string"
        ["_xml:protected"] => string(213) "mt.getRecentPostTitles1
usernamepassword"
      }
      ["type"] => string(6) "string"
    }
  }
}

What strikes is that in version 1.10.2, "mt.getRecentPostTitles" is intermingled with the method "metaWeblog.getPost" although these calls have nothing to do with each other.

It is to be assumed that this was introduced in version 1.10.xx

Comments

Wrapped code with code-Tag to improve readability.