Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.14.0

Bug #14782 logic problem in SOAP_Base bulids multidimensional arrays instead of flat
Submitted: 2008-10-13 03:10 UTC
From: gram Assigned: doconnor
Status: Closed Package: SOAP (version 0.12.0)
PHP Version: 5.2.3 OS: Ububntu 7.10
Roadmaps: (Not assigned)    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 20 + 48 = ?

 
 [2008-10-13 03:10 UTC] gram (Steve Graham)
Description: ------------ This is the only SOAP client I have tested that produced this problem. All others produced flat arrays for this circumstance. I have several 'Item' tags coming back sequentially in my xml as value to 'Item' Container tag. In Base.php line 826 object SOAP_Base method _decode(): $return->{$item->name} = array($return->{$item->name}, $d); If $return->{$item->name} is already an array, this will end up building a multidimensional array because this line builds a new array using the existing value (which could be an array) and the newly decoded object. Result == array(array($obj, $obj),$obj). This problem compounds as items are added to this array building progressively deeper arrays. I am using this class to process requests from Amazon Associates Services which will always try to return ten 'Items' as a the value to a single tags value. I end up with an array that has ten elements in it, the first is ten levels deep, the second 9 levels deep etc... I replaced line 826 with: if(is_array($return->{$item->name})){ $return->{$item->name} = array_merge($return->{$item->name},array($d)); } else { $return->{$item->name} = array($return->{$item->name}, $d); } This completely solved the problem, and I have seen no adverse effects in any other areas of the code. I do not use the same coding standards that Pear uses, so not attaching a patch. Also not filling in the remainder of this form as the problem is self evident. Just wanted to pass it on. Thanks for the great work folks! Gram

Comments

 [2008-10-15 12:12 UTC] doconnor (Daniel O'Connor)
Steve, I don't suppose you can write a small executable test case that demonstrates this? The reason we love that kind of test, and actual patches, is because we can make sure that when we fix this problem; it stays fixed - or we can easily back the changes out if it breaks other tests. Additionally, we all speak PHP; so we understand exactly what you mean and change better assess the potential changes.
 [2008-10-15 13:52 UTC] gram (Steve Graham)
I can put something together and submit a patch as well. Its a small patch, so making it compliant with Pear coding standards won't be an issue. Give me a couple of days (right in the middle of a big project) and I will submit a test case as well. I am writing code that depends upon this and would rather it stay fixed. Forgive the brevity of my submission. It was late, and I did not want to blow through the fix without handing off the solution. Will get right back to you.
 [2008-10-15 16:11 UTC] gram (Steve Graham)
Test Case (requires amazon web services developer key): <?php require_once('SOAP/Client.php'); $params->AWSAccessKeyId = 'replace with AWS Developer Key'; $params->Request->SearchIndex = 'Books'; $params->Request->Keywords = 'yoga'; $params->Request->ResponseGroup = 'Small'; $amazon = new SOAP_WSDL('http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl'); $asearch = $amazon->getProxy(); $test = $asearch->ItemSearch($params); echo '<pre>'.print_r($test['Items'],true).'</pre>' ?> The 'Item' array of the returned 'Items' object is the problem. It should return a flat array. Instead it returns a multidimensional array. If I try to put it into a comment here it will be many pages long. So will summarize here. The 'Item' array is structured like this: Element [0][0][0][0][0][0][0][0] = array([all ten returned items]) Element [1][0][0][0][0][0][0] = array([first nine returned items]) Element [2][0][0][0][0][0] = array([first eight returned items]) Element [3][0][0][0][0] = array([first seven returned items]) Element [4][0][0][0] = array([first six returned items]) Element [5][0][0] = array([first five returned items]) Element [6][0] = array([first four returned items]) Element [7] = array([first three returned items]) Element [8] = array([first two returned items]) It should be a flat array with all ten returned item objects in it. If one the project devs wants to test and does not have an Amazon Web Services developer key, please send me an email and I will provide mine for testing.
 [2008-10-25 06:44 UTC] doconnor (Daniel O'Connor)
Thanks Steve!
 [2012-01-14 19:08 UTC] doconnor (Daniel O'Connor)
clockwerx@clockwerx-desktop:~/SOAP$ patch -p1 < patch-download.php\? id\=14782\&patch\=fix-decode-array-problem\&revision\=1224083752 can't find file to patch at input line 5 Perhaps you used the wrong -p or --strip option? The text leading up to this was: -------------------------- |Index: Base.php |================================================== ================= |--- Base.php (revision 2020) |+++ Base.php (revision 2021) -------------------------- File to patch: Base.php patching file Base.php Hunk #1 FAILED at 823. 1 out of 1 hunk FAILED -- saving rejects to file Base.php.rej clockwerx@clockwerx-desktop:~/SOAP$ svn revert Base.php
 [2012-01-14 19:11 UTC] doconnor (Daniel O'Connor)
-Status: Assigned +Status: Closed -Assigned To: yunosh +Assigned To: doconnor
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.