Zend_XmlRpc - is this a bug?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_XmlRpc - is this a bug?

alesl
Hi,

After updating to ZF 1.5RC3 Zend_XmlRpc_Client starts to throw
exceptions whenever empty array value was passed in as parameter. Empty
array should be convertet to XML-RPC type array, but is convertet to
XML-RPC type struct.

I've looked into svn log. This happened in revision 8614 when matthew
merged to release branch.

 Exception:


    Incorrect parameters passed to method: Wanted array, got struct at
    param 7

$params
|array (
  0 =>
  array (
    'remote_addr' => '127.0.0.1',
    'request_uri' => '/',
    'server_name' => 'dev.zauspeh.localhost',
    'http_host' => 'dev.zauspeh.localhost',
    'accept_language' => 'en-us,en;q=0.5',
    'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12',
    'cookies' =>
    array (
      'ZDEDebuggerPresent' => 'php,phtml,php3',
      'app' => '36085727310717e09f509420bd48ef4b',
    ),
  ),
  1 => 'zone:3',
  2 => 0,
  3 => '',
  4 => '',
  5 => false,
  6 =>
  array (
  ),
) |

Another strange one is this.
If i try to create XmlRpc Value explicit:
$args = array(
            $aRemoteInfo,
            $what,
            $campaignid,
            $target,
            $source,
            (bool)$withText,
            new Zend_XmlRpc_Value_Array($xmlContext)
        );

Fatal Error is produced.

Fatal error:  Class 'Zend_XmlRpc_Value_Collection' not found in D:\library\Zend Framework\library\Zend\XmlRpc\Value\Struct.php on line 36 !!




Reply | Threaded
Open this post in threaded view
|

Re: Zend_XmlRpc - is this a bug?

weierophinney
Administrator
-- Aleš Lončar <[hidden email]> wrote
(on Friday, 14 March 2008, 10:27 AM +0100):
> After updating to ZF 1.5RC3 Zend_XmlRpc_Client starts to throw exceptions
> whenever empty array value was passed in as parameter. Empty array should
> be convertet to XML-RPC type array, but is convertet to XML-RPC type
> struct.
>
> I've looked into svn log. This happened in revision 8614 when matthew
> merged to release branch.

That particular changeset was made to speed up differentiating arrays
from structs, and utilizes a tried-and-true approach for doing so.

Now, from what I can tell, however, the issue is with empty arrays that
are passed in, and that leaves us with a pretty huge issue: is an empty
array treated as a struct or as an array?

Clearly, the code as provided will treat it as a struct, because it's
comparing:

    array() TO array(0)

But even if we were comparing array() to array(), would the value
represent a struct or an array? Rolling back the changeset would help
only the case of an empty array being passed, but not an empty struct.

I'm unsure how to correct the issue, honestly. Since PHP does not
differentiate between arrays and hashes, an empty array() could
represent either. Probably the only good solution is to add some checks
in Zend_XmlRpc_Client to allow either any empty
Zend_XmlRpc_Value_Collection be considered valid when either a struct or
array is expected.

In the meantime, is it possible for you to send other values other than
an empty array? For instance, is that parameter optional? or can it
accept other values?

<snip>

> Another strange one is this.
> If i try to create XmlRpc Value explicit:
> $args = array(
>            $aRemoteInfo,
>            $what,
>            $campaignid,
>            $target,
>            $source,
>            (bool)$withText,
>            new Zend_XmlRpc_Value_Array($xmlContext)
>        );
>
> Fatal Error is produced.
>
> Fatal error:  Class 'Zend_XmlRpc_Value_Collection' not found in
> D:\library\Zend Framework\library\Zend\XmlRpc\Value\Struct.php on line 36
> !!

I cannot reproduce this. Looking in Zend/XmlRpc/Value/Struct.php,
there's a definite require_once 'Zend/XmlRpc/Value/Collection.php', and
that file itself has appropriate require statements to get its
dependencies.

--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Reply | Threaded
Open this post in threaded view
|

Re: Zend_XmlRpc - is this a bug?

weierophinney
Administrator
In reply to this post by alesl
-- Aleš Lončar <[hidden email]> wrote
(on Friday, 14 March 2008, 10:27 AM +0100):

> After updating to ZF 1.5RC3 Zend_XmlRpc_Client starts to throw exceptions
> whenever empty array value was passed in as parameter. Empty array should
> be convertet to XML-RPC type array, but is convertet to XML-RPC type
> struct.
>
> I've looked into svn log. This happened in revision 8614 when matthew
> merged to release branch.
>
> Exception:
>
>
>    Incorrect parameters passed to method: Wanted array, got struct at
>    param 7

Aleš -- that exception message isn't one of ZF's, so I'm assuming it's
from your XML-RPC server. Can you provide me the parameters you're
passing in your client?

>
> $params
> |array (
>  0 =>  array (
>    'remote_addr' => '127.0.0.1',
>    'request_uri' => '/',
>    'server_name' => 'dev.zauspeh.localhost',
>    'http_host' => 'dev.zauspeh.localhost',
>    'accept_language' => 'en-us,en;q=0.5',
>    'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12',
>    'cookies' =>    array (
>      'ZDEDebuggerPresent' => 'php,phtml,php3',
>      'app' => '36085727310717e09f509420bd48ef4b',
>    ),
>  ),
>  1 => 'zone:3',
>  2 => 0,
>  3 => '',
>  4 => '',
>  5 => false,
>  6 =>  array (
>  ),
> ) |
>
> Another strange one is this.
> If i try to create XmlRpc Value explicit:
> $args = array(
>            $aRemoteInfo,
>            $what,
>            $campaignid,
>            $target,
>            $source,
>            (bool)$withText,
>            new Zend_XmlRpc_Value_Array($xmlContext)
>        );
<snip>

--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/
Reply | Threaded
Open this post in threaded view
|

Re: Zend_XmlRpc - is this a bug?

till
In reply to this post by weierophinney
On Fri, Mar 14, 2008 at 2:20 PM, Matthew Weier O'Phinney
<[hidden email]> wrote:

> -- Aleš Lončar <[hidden email]> wrote
>  (on Friday, 14 March 2008, 10:27 AM +0100):
>
> > After updating to ZF 1.5RC3 Zend_XmlRpc_Client starts to throw exceptions
>  > whenever empty array value was passed in as parameter. Empty array should
>  > be convertet to XML-RPC type array, but is convertet to XML-RPC type
>  > struct.
>  >
>  > I've looked into svn log. This happened in revision 8614 when matthew
>  > merged to release branch.
>
>  That particular changeset was made to speed up differentiating arrays
>  from structs, and utilizes a tried-and-true approach for doing so.
>
>  Now, from what I can tell, however, the issue is with empty arrays that
>  are passed in, and that leaves us with a pretty huge issue: is an empty
>  array treated as a struct or as an array?
>
>  Clearly, the code as provided will treat it as a struct, because it's
>  comparing:
>
>     array() TO array(0)
>
>  But even if we were comparing array() to array(), would the value
>  represent a struct or an array? Rolling back the changeset would help
>  only the case of an empty array being passed, but not an empty struct.
>
>  I'm unsure how to correct the issue, honestly. Since PHP does not
>  differentiate between arrays and hashes, an empty array() could
>  represent either. Probably the only good solution is to add some checks
>  in Zend_XmlRpc_Client to allow either any empty
>  Zend_XmlRpc_Value_Collection be considered valid when either a struct or
>  array is expected.

I'm just wondering if you could leave it as-is and people instead pass
in an instance of Zend_XmlRpc_Value to force whatever they want?

It makes it a bit more complex (I guess), but it could be a clean solution:
<http://framework.zend.com/manual/en/zend.xmlrpc.client.html#zend.xmlrpc.value.parameters.xmlrpc-value>

Till
Reply | Threaded
Open this post in threaded view
|

Re: Zend_XmlRpc - is this a bug?

weierophinney
Administrator
-- till <[hidden email]> wrote
(on Friday, 21 March 2008, 04:20 PM +0100):

> On Fri, Mar 14, 2008 at 2:20 PM, Matthew Weier O'Phinney
> <[hidden email]> wrote:
> > -- Aleš Lončar <[hidden email]> wrote
> >  (on Friday, 14 March 2008, 10:27 AM +0100):
> >
> > > After updating to ZF 1.5RC3 Zend_XmlRpc_Client starts to throw exceptions
> >  > whenever empty array value was passed in as parameter. Empty array should
> >  > be convertet to XML-RPC type array, but is convertet to XML-RPC type
> >  > struct.
> >  >
> >  > I've looked into svn log. This happened in revision 8614 when matthew
> >  > merged to release branch.
> >
> >  That particular changeset was made to speed up differentiating arrays
> >  from structs, and utilizes a tried-and-true approach for doing so.
> >
> >  Now, from what I can tell, however, the issue is with empty arrays that
> >  are passed in, and that leaves us with a pretty huge issue: is an empty
> >  array treated as a struct or as an array?
> >
> >  Clearly, the code as provided will treat it as a struct, because it's
> >  comparing:
> >
> >     array() TO array(0)
> >
> >  But even if we were comparing array() to array(), would the value
> >  represent a struct or an array? Rolling back the changeset would help
> >  only the case of an empty array being passed, but not an empty struct.
> >
> >  I'm unsure how to correct the issue, honestly. Since PHP does not
> >  differentiate between arrays and hashes, an empty array() could
> >  represent either. Probably the only good solution is to add some checks
> >  in Zend_XmlRpc_Client to allow either any empty
> >  Zend_XmlRpc_Value_Collection be considered valid when either a struct or
> >  array is expected.
>
> I'm just wondering if you could leave it as-is and people instead pass
> in an instance of Zend_XmlRpc_Value to force whatever they want?
>
> It makes it a bit more complex (I guess), but it could be a clean solution:
> <http://framework.zend.com/manual/en/zend.xmlrpc.client.html#zend.xmlrpc.value.parameters.xmlrpc-value>

No need -- I have it fixed in trunk and the release-1.5 branch now. I
actually put in code that uses the existing server introspection to
explicitly cast empty arrays to the correct XML-RPC type as detected on
the server. Additionally, there's a check in Zend_XmlRpc_Value that does
*not* cast empty arrays as structs by default.

--
Matthew Weier O'Phinney
PHP Developer            | [hidden email]
Zend - The PHP Company   | http://www.zend.com/