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

Bug #303 (De-)Serializing problems with arrays
Submitted: 2003-11-26 23:12 UTC
From: yunosh Assigned: arnaud
Status: Closed Package: SOAP
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2003-11-26 23:12 UTC] yunosh
Description: ------------ The base class handles (de-)serializing of arrays differently than of hashes. SOAP_Base::_isHash checks if there is a non-integer key to determine hashes. But unfortunately the code that deals with arrays doesn't handle keys that are not continously and starting with 0. An array like array(5 => 'foo', 2 => 'bar') will be considered an array but not correct serialized. I don't know much enough about SOAP to say if this is still a valid array in SOAP's terms or already a struct, but I assumed the former and fixed the de-/serializing code: --- Base.php 2003-08-08 07:23:33.000000000 +0200 +++ /usr/share/php/SOAP/Base.php 2003-11-27 00:01:48.000000000 +0100 @@ -463,8 +463,7 @@ // serialize each array element $ar_size = count($value); - for ($i=0; $i < $ar_size; $i++) { - $array_val =& $value[$i]; + foreach ($value as $array_val) { if ($this->_isSoapValue($array_val)) { $array_type = $array_val->type; $array_types[$array_type] = 1; @@ -598,12 +597,15 @@ $type = 'Struct'; } else { $ar_size = count($value); - if ($ar_size > 0 && is_a($value[0],'soap_value')) { - // fixme for non-wsdl structs that are all teh same type + reset($value); + $key1 = key($value); + if ($ar_size > 0 && is_a($key1,'soap_value')) { + // fixme for non-wsdl structs that are all the same type + $key2 = key($value); if ($ar_size > 1 && - $this->_isSoapValue($value[0]) && - $this->_isSoapValue($value[1]) && - $value[0]->name != $value[1]->name) { + $this->_isSoapValue($key1) && + $this->_isSoapValue($key2) && + $key1->name != $key2->name) { // this is a struct, not an array $type = 'Struct'; } else { Assuming and fixing the latter case wouldn't be much more work, _isHash() would only have to check if the keys start with 0 and increment by 1.

Comments

 [2004-07-11 22:47 UTC] gurugeek
Dear Maintainer, Your package SOAP has currently 15+ open bugs. We urge you to take the necessary steps to solve the reported issues at your soonest convenience. If the bug issue hasn’t been addressed yet you are kindly asked to take the necessary steps to ensure a prompt resolution of the problem. If you already addressed the reported problem feel free to change the bug status as soon as possible. Regards David Costa PEAR Quality Assurance pear-qa@lists.php.net
 [2004-11-28 23:12 UTC] yunosh
This is an updated patch. Will there ever be a fixed package or a version update almost one year after the last RC? If not, I will think about forking the package. --- Base.php 2004-11-29 00:09:41.868225296 +0100 +++ /usr/share/php/SOAP/Base.php 2004-11-29 00:08:11.658939192 +0100 @@ -463,8 +461,7 @@ // serialize each array element $ar_size = count($value); - for ($i=0; $i < $ar_size; $i++) { - $array_val =& $value[$i]; + foreach ($value as $array_val) { if ($this->_isSoapValue($array_val)) { $array_type = $array_val->type; $array_types[$array_type] = 1; @@ -598,12 +595,15 @@ $type = 'Struct'; } else { $ar_size = count($value); - if ($ar_size > 0 && isset($value[0]) && is_a($value[0],'soap_value')) { - // fixme for non-wsdl structs that are all teh same type + reset($value); + $key1 = key($value); + if ($ar_size > 0 && is_a($key1,'soap_value')) { + // fixme for non-wsdl structs that are all the same type + $key2 = key($value); if ($ar_size > 1 && - $this->_isSoapValue($value[0]) && - $this->_isSoapValue($value[1]) && - $value[0]->name != $value[1]->name) { + $this->_isSoapValue($key1) && + $this->_isSoapValue($key2) && + $key1->name != $key2->name) { // this is a struct, not an array $type = 'Struct'; } else {
 [2004-12-04 00:19 UTC] arnaud
I applied your patch to CVS. Instead of forking if you want to take over the package you're very welcome to do it. Drop me a mail if you are interested.
 [2005-01-19 08:42 UTC] yunosh
Did you ever get my mail response?
 [2006-12-23 20:30 UTC] cellog (Greg Beaver)
assign to fixer for stats