Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

SERIALIZER_IGBINARY and objects containing multiple DateTime object instances #8

Closed
romainneutron opened this Issue · 2 comments

2 participants

@romainneutron

Hello,

I'm facing a weird issue : when I set an object containing more than one DateTime object property with the igbinary serializer option, the first datetime object is restored correctly, others are restored as incomplete PHP class

Here's a piece of code to reproduce the bug :

    date_default_timezone_set('Europe/Berlin');
    
    class baba
    {
            protected $date1;
            protected $date2;
    
            public function __construct()
            {
                    $this->date1 = new DateTime('2011-04-07 13:17:09');
                    $this->date2 = new DateTime('2011-04-10 15:17:09');
                    return $this;
            }
            public function print_datas()
            {
                    echo $this->date1->format(DATE_ATOM)."\n";
                    echo $this->date2->format(DATE_ATOM)."\n";
                    return $this;
            }
    
    }
    
    $baba = new baba();
    
    $redis = new Redis();
    $redis->connect('127.0.0.1', 6379);
    $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
    
    $redis->set("__baba__", $baba);
    
    $cached_datas = $redis->get("__baba__");
    
    var_dump($cached_datas);
    
    $cached_datas->print_datas();
    
    $redis->delete("__baba__");
    

This bad behavior does not exists when I use the default PHP serializer.

This bad behavior does not exists when I use igbinary_serialize

I use igbinary 1.1.1 and phpredis 2.1.0.

@nicolasff
Owner

Hello Romain,

Could you please check that it works with the pecl branch on github? Make sure to run ./configure --enable-redis-igbinary prior to compiling.
This branch will be merged into master soon.

Nicolas

@romainneutron

Hello Nicolas,

I confirm you that the problem does not occur anymore in the pecl branch
For information, when will you merge this branch into master ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.