Skip to content

Commit 199d5e6

Browse files
committed
Fix issue with interned igbinary strings.
Possibly related to ticket phpredis#145.
1 parent ae147cf commit 199d5e6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

igbinary/igbinary.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ inline static int igbinary_serialize_data_init(struct igbinary_serialize_data *i
454454
hash_si_init(&igsd->objects, 16);
455455
}
456456

457-
igsd->compact_strings = (bool)IGBINARY_G(compact_strings);
457+
igsd->compact_strings = 1; // PHPHREDIS WARNING: DO NOT CHANGE.
458458

459459
return r;
460460
}

tests/TestRedis.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,6 +2810,13 @@ private function checkSerializer($mode) {
28102810
$this->assertTrue($data['data'] === 'test 1');
28112811
$this->assertTrue($data['session_id'] === 'test 2');
28122812

2813+
// issue #145, serializer with objects.
2814+
$this->redis->set('x', array(new stdClass, new stdClass));
2815+
$x = $this->redis->get('x');
2816+
$this->assertTrue(is_array($x));
2817+
$this->assertTrue(is_object($x[0]) && get_class($x[0]) === 'stdClass');
2818+
$this->assertTrue(is_object($x[1]) && get_class($x[1]) === 'stdClass');
2819+
28132820
// revert
28142821
$this->assertTrue($this->redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE) === TRUE); // set ok
28152822
$this->assertTrue($this->redis->getOption(Redis::OPT_SERIALIZER) === Redis::SERIALIZER_NONE); // get ok

0 commit comments

Comments
 (0)