[dev] Horde-Kolab-Storage - unserialize issue

Remi Collet remi at fedoraproject.org
Sat Aug 16 16:58:12 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

With PHP 5.6.0 test suite fails :

There were 51 errors:

1) Horde_Kolab_Storage_Unit_Data_BaseTest::testDefaultType
Erroneous data format for unserializing 'Horde_Mime_Part'

/dev/shm/BUILD/php-horde-Horde-Kolab-Storage-2.1.0/Horde_Kolab_Storage-2.1.0/lib/Horde/Kolab/Storage/Driver/Mock/Data.php:103
...


Digging in this issue.

First: you should be awarer that "serialized" data is a very bad
pratice for storage... no warranty to work accross various versions.

See the recent discussion about the "unserialize" regression/issue...

The test/Horde/Kolab/Storage/fixtures/event.struct contains:
O:15:"Horde_Mime_Part":...

Which is wrong, as Horde_Mime_Part implements Serializable.
(should be C:... with PHP > 5.4)


Proof.

<?php
require 'Horde/Autoloader/Default.php';
$txt = file_get_contents("event.struct");
var_dump($ser = base64_decode($txt));
$obj = unserialize($ser);
var_dump($obj);
var_dump($ser = serialize($obj));

PHP Fatal error:  Call to a member function getArrayCopy() on a
non-object in /usr/share/pear/Horde/Mime/Part.php on line 2321

Analyse: with "O:..;" the unserialize method is not used.
So the object is create, but without the correct unserializer.


Fixing the fixture file.

I add in the Horde_Mime_Part the fixit method

   public function fixit()
   {
      if (is_array($this->_contentTypeParams)) {
         echo "Fix\n";
         $this->_contentTypeParams =
    new Horde_Support_CaseInsensitiveArray($this->_contentTypeParams);
      }
      foreach($this->_parts as $i => $p) {
          echo "Part $i\n";
          $p->fixit();
      }
   }

This allow to fix the unserialized object,
and then to serialize it and save it.

Then the new fixture file contains:
C:15:"Horde_Mime_Part":978:{a:20:{i:0;i:1

Then this file can be used with PHP 5.4, 5.5 and 5.6.


The attached patch add this "fixed" fixture file, and use it.

Test suite pass with php 5.3, 5.4, 5.5, 5.6


Can you please review it ?

Regards,
Remi.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlPvjaQACgkQYUppBSnxahgE7ACg1N3PdQpiPc/up0PKTM00vE5s
sAAAoPi/ORQN8PPW2+C45aUjNA3DZ669
=VuPw
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Horde_Kolab_Storage-php54.patch
Type: text/x-patch
Size: 2538 bytes
Desc: not available
URL: <http://lists.horde.org/archives/dev/attachments/20140816/90f43029/attachment.bin>


More information about the dev mailing list