8000 SERIALIZER_IGBINARY and objects containing multiple DateTime object instances · Issue #8 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content
8000

SERIALIZER_IGBINARY and objects containing multiple DateTime object instances #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
romainneutron opened this issue Apr 13, 2011 · 2 comments

Comments

@romainneutron
Copy link

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
Copy link
Member

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
Copy link
Author

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 ?

@bigfg bigfg mentioned this issue Aug 9, 2016
@liupdhc liupdhc mentioned this issue Apr 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0