Re: Horde-Kolab-Storage - unserialize issue

Jan Schneider <[email protected]>
Newsgroups gmane.comp.horde.devel
Message-ID <[email protected]>
Zitat von Remi Collet <[email protected]>:

> 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 ?)

This has been fixed in Git already.

-- 
Jan Schneider
The Horde Project
http://www.horde.org/
https://www.facebook.com/hordeproject

-- 
dev mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.