[dev] Horde-Kolab-Storage - unserialize issue

Remi Collet remi at fedoraproject.org
Sat Aug 16 17:08:17 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.


This patch add this "fixed" fixture file, and use it.
https://raw.githubusercontent.com/remicollet/remirepo/a8cb881f1ae02264496ca76c6287a4652a52e8c8/php/horde/php-horde-Horde-Kolab-Storage/Horde_Kolab_Storage-php54.patch


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


Can you please review it ?

Regards,
Remi.


P.S. resent as it seems previous was refused
(because of attached patch ?)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlPvkAEACgkQYUppBSnxahjArACeMvSlmhmmz7EmEA6poMEcuHnt
ofgAoPiBJVW3cbEddigHXTkswXcpkbC/
=iw5+
-----END PGP SIGNATURE-----


More information about the dev mailing list