Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 11a9292

Browse files
Merge branch 'hotfix/allow_null_set_options' into develop
2 parents f73898d + 32837e0 commit 11a9292

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

redis.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,9 @@ PHP_METHOD(Redis, set) {
836836

837837
/* Our optional argument can either be a long (to support legacy SETEX */
838838
/* redirection), or an array with Redis >= 2.6.12 set options */
839-
if(z_opts && Z_TYPE_P(z_opts) != IS_LONG && Z_TYPE_P(z_opts) != IS_ARRAY) {
839+
if(z_opts && Z_TYPE_P(z_opts) != IS_LONG && Z_TYPE_P(z_opts) != IS_ARRAY
840+
&& Z_TYPE_P(z_opts) != IS_NULL)
841+
{
840842
RETURN_FALSE;
841843
}
842844

tests/TestRedis.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ public function testExtendedSet() {
264264
$this->assertTrue($this->redis->set('foo','barbaz', Array('not-valid','nx','invalid','ex'=>200)));
265265
$this->assertEquals($this->redis->ttl('foo'), 200);
266266
$this->assertEquals($this->redis->get('foo'), 'barbaz');
267+
268+
/* Pass NULL as the optional arguments which should be ignored */
269+
$this->redis->del('foo');
270+
$this->redis->set('foo','bar', NULL);
271+
$this->assertEquals($this->redis->get('foo'), 'bar');
272+
$this->assertTrue($this->redis->ttl('foo')<0);
267273
}
268274

269275
public function testGetSet() {

0 commit comments

Comments
 (0)