ZF-2215: Zend_Rest_Client adds last given argument as arg1
Description
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.
$client = new Zend_Rest_Client('http://www.example.com/rest/');
$client->method('divide');
$client->one(4);
$client->two(3);
$erg = $client->get();
get() uses this URL:
/rest/?method=divide&arg1=3&one=4&two=3&rest=1
Comments
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];
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 (yoshida@zend.co.jp) 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 (yoshida@zend.co.jp) 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 (yoshida@zend.co.jp) 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.