ZF-2215: Zend_Rest_Client adds last given argument as arg1

Issue Type: Bug Created: 2007-11-18T06:16:01.000+0000 Last Updated: 2012-03-28T02:12:44.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)

Reporter: Carsten Möhrke (donnerchen) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Rest_Client

Related issues: - ZF-4089



When using named arguments Zend_Rest_Client adds an additional argument named arg1 to the call. In combination with Zend_Rest_Server the first given argument is overwritten by the last one.

<pre class="highlight">
$client = new Zend_Rest_Client('<a href=""></a>');

$erg =  $client->get();

get() uses this URL:

<pre class="highlight">


Posted by Johannes Schlimm (schlimmer) on 2008-05-07T09:18:55.000+0000

Had the same issue. Solved the problem by commenting out one line of Zend/Rest/Client.php. See below: $this->_data['arg1'] = $args[0];

public function __call($method, $args)
    $methods = array('post', 'get', 'delete', 'put');

    if (in_array(strtolower($method), $methods)) {
        if (!isset($args[0])) {
            $args[0] = $this->_uri->getPath();
        $this->_data['rest'] = 1;
        $data = array_slice($args, 1) + $this->_data;
        $response = $this->{'rest' . $method}($args[0], $data);
        return new Zend_Rest_Client_Result($response->getBody());
    } else {
        // More than one arg means it's definitely a Zend_Rest_Server
        if (sizeof($args) == 1) {
            $this->_data[$method] = $args[0];
            //$this->_data['arg1']  = $args[0];
        } else {
            $this->_data['method'] = $method;
            if (sizeof($args) > 0) {
                foreach ($args as $key => $arg) {
                    $key = 'arg' . $key;
                    $this->_data[$key] = $arg;
        return $this;

Posted by Herbert G. Fischer (hgfischer) on 2008-06-04T11:46:55.000+0000

Looks like issues ZF-2467, ZF-2215, ZF-2044 are all related to this problem.

Posted by Johannes Schlimm (schlimmer) on 2008-06-10T02:04:47.000+0000

This issue is still existing in v1.5.2.

Posted by Johannes Schlimm (schlimmer) on 2008-08-25T02:25:27.000+0000

...and is still existing in v1.5.3...

Posted by old of Satoru Yoshida ( on 2008-10-09T06:24:57.000+0000

Does it depend on ZF-4089, doesn't it?

Posted by Johannes Schlimm (schlimmer) on 2008-10-17T16:17:37.000+0000

Sorry, but the changes in v1.6.2 doesn't fix this issue. Have a look at the original description. When stepping through a debugger one can see that the first call $client->method('divide'); results in $this->_data['method'] being set to 'method' on line 240. $this->_data['arg1'] is set to 'divide' on line 241.

Maybe the whole call sequence used in the original description is wrong. But I have my doubts. When writing line 240 as $this->_data[$method] = $args[0]; and omitting line 241 the call sequence used in the original desription of this issue will work as expected. And it doesn't seem to have any problematic side effects.

Posted by Johannes Schlimm (schlimmer) on 2008-10-18T02:42:16.000+0000

I have to correct my last comment. The described workaround doesn't work if the call uses exactly one parameter. So it seems that Zend_Rest_Client cannot be used with the call sequence described above by Carsten Möhrke. The reason why I also had problems with this is because I followed a chapter in the (german) book about Zend Framework written by Carsten Möhrke.

So there are two options:

1: Zend_Rest_Client is intended to support a call sequence where one uses a call of e.g. client->method('divide') and setting named parameters the way Carsten Möhrke did above. Then this issue is still unresolved.

2: Zend_Rest_Client is not intended to support a call sequence as in Carsten Möhrke's above example.

Posted by old of Satoru Yoshida ( on 2008-10-20T06:07:00.000+0000

Thank You for Your detailed explanation , Johannes Schlimm.

Now, I understand if we call functions twice more before post(), get(), delete() or put(), it causes wrong uri parameter.

Posted by old of Satoru Yoshida ( on 2008-10-20T23:28:25.000+0000

Solved in r12048

Posted by Wil Sinclair (wil) on 2008-11-13T14:10:07.000+0000

Changing issues in preparation for the 1.7.0 release.

Have you found an issue?

See the Overview section for more details.


© 2006-2022 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.