From 199d5e696fa2dccd058f2b6c4271a494ace1c349 Mon Sep 17 00:00:00 2001 From: Nicolas Favre-Felix Date: Thu, 15 Mar 2012 00:04:48 +0000 Subject: [PATCH] Fix issue with interned igbinary strings. Possibly related to ticket #145. --- igbinary/igbinary.c | 2 +- tests/TestRedis.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/igbinary/igbinary.c b/igbinary/igbinary.c index 276aeee..33feeaa 100644 --- a/igbinary/igbinary.c +++ b/igbinary/igbinary.c @@ -454,7 +454,7 @@ inline static int igbinary_serialize_data_init(struct igbinary_serialize_data *i hash_si_init(&igsd->objects, 16); } - igsd->compact_strings = (bool)IGBINARY_G(compact_strings); + igsd->compact_strings = 1; // PHPHREDIS WARNING: DO NOT CHANGE. return r; } diff --git a/tests/TestRedis.php b/tests/TestRedis.php index b1803c1..a8dfa51 100644 --- a/tests/TestRedis.php +++ b/tests/TestRedis.php @@ -2810,6 +2810,13 @@ class Redis_Test extends TestSuite $this->assertTrue($data['data'] === 'test 1'); $this->assertTrue($data['session_id'] === 'test 2'); + // issue #145, serializer with objects. + $this->redis->set('x', array(new stdClass, new stdClass)); + $x = $this->redis->get('x'); + $this->assertTrue(is_array($x)); + $this->assertTrue(is_object($x[0]) && get_class($x[0]) === 'stdClass'); + $this->assertTrue(is_object($x[1]) && get_class($x[1]) === 'stdClass'); + // revert $this->assertTrue($this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE) === TRUE); // set ok $this->assertTrue($this->redis->getOption(Redis::OPT_SERIALIZER) === Redis::SERIALIZER_NONE); // get ok