PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Web Services » XML_RPC » Bug #3600

XML_RPC_Value's getval() doesn't properly recurse arrays and objects

Details

Submitted2005-02-25 20:33 UTC
Frommdabney at cavoksolutions dot com
Assigneddanielc
StatusBogus
PackageXML_RPC
PHP Version5.0.3
OSLinux 2.6.9-gentoo-r9
Roadmaps(Not assigned)

Comments

[2005-02-25 20:33 UTC] mdabney at cavoksolutions dot com

Description:
------------
The summary pretty much says it all, and the fix is simple.

Reproduce code:
---------------
Here's the patch:

--- XML.orig/RPC.php 2005-02-25 14:39:02.513888616 -0600
+++ XML/RPC.php 2005-02-25 14:35:45.059906184 -0600
@@ -977,7 +977,7 @@

if (is_array($b)) {
foreach ($b as $id => $cont) {
- $b[$id] = $cont->scalarval();
+ $b[$id] = $cont->getval();
}
}

@@ -985,7 +985,7 @@
if (is_object($b)) {
$t = get_object_vars($b);
foreach ($t as $id => $cont) {
- $t[$id] = $cont->scalarval();
+ $t[$id] = $cont->getval();
}
foreach ($t as $id => $cont) {
eval('$b->'.$id.' = $cont;');

[2005-02-25 20:55 UTC] mdabney at cavoksolutions dot com

Forgot to note that this is for XML_RPC 1.1.0

[2005-02-25 22:00 UTC] mdabney at cavoksolutions dot com

Yeah, this problem persists in 1.2.0RC7. Here's the scenario:

Given this XMLRPC response:

<code><pre><?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>perms</name>
<value>
<struct>
<member>
<name>test</name>
<value>
<int>1</int>
</value>
</member>
</struct>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse></pre></code>

A getval() of that returns this:

<code><pre>Array
(
[perms] => Array
(
[test] => XML_RPC_Value Object
(
[me] => Array
(
[int] => 1
)

[mytype] => 1
)

)

)</pre></code>

If you apply the same fix to 1.2.0RC7 (changing the scalarval's to getval's), it returns this:

<code><pre>Array
(
[perms] => Array
(
[test] => 1
)

)</pre></code>

Here's the patch for 1.2.ORC7:

<code><pre>--- XML.orig/RPC.php 2005-02-25 16:06:33.939550568 -0600
+++ XML/RPC.php 2005-02-25 16:04:56.792319192 -0600
@@ -1529,7 +1529,7 @@

if (is_array($b)) {
foreach ($b as $id => $cont) {
- $b[$id] = $cont->scalarval();
+ $b[$id] = $cont->getval();
}
}

@@ -1537,7 +1537,7 @@
if (is_object($b)) {
$t = get_object_vars($b);
foreach ($t as $id => $cont) {
- $t[$id] = $cont->scalarval();
+ $t[$id] = $cont->getval();
}
foreach ($t as $id => $cont) {
eval('$b->'.$id.' = $cont;');</pre></code>

[2005-02-25 22:01 UTC] mdabney at cavoksolutions dot com

Ignore all the <code></code>'s and <pre></pre>'s.

[2005-02-28 18:42 UTC] mdabney at cavoksolutions dot com

We ARE talking about getval(), right? Because that example doesn't use it, and nowhere does that function get called by anything else in the XML_RPC package.

[2005-02-28 18:44 UTC] mdabney at cavoksolutions dot com

We ARE talking about getval(), right? Because that example doesn't use it, and nowhere does that function get called by anything else in the XML_RPC package.