Skip to content

Commit 59a2886

Browse files
Merge branch 'hotfix/hmget_no_valid_keys'
2 parents 19e6f31 + a0e9b65 commit 59a2886

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

redis.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4993,6 +4993,13 @@ PHP_METHOD(Redis, hMget) {
49934993
}
49944994
}
49954995

4996+
// This is a failure if none of the keys were valid
4997+
if(i == 0) {
4998+
efree(cmd);
4999+
efree(z_keys);
5000+
RETURN_FALSE;
5001+
}
5002+
49965003
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
49975004
IF_ATOMIC() {
49985005
redis_sock_read_multibulk_reply_assoc(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, z_keys);

tests/TestRedis.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,6 +2282,8 @@ public function testHashes() {
22822282
$this->assertFalse(array(123 => 'x') === $this->redis->hMget('h', array(123)));
22832283
$this->assertTrue(array(123 => FALSE) === $this->redis->hMget('h', array(123)));
22842284

2285+
// Test with an array populated with things we can't use as keys
2286+
$this->assertTrue($this->redis->hmget('h', Array(false,NULL,false)) === FALSE);
22852287

22862288
// hmget/hmset with numeric fields
22872289
$this->redis->del('h');

0 commit comments

Comments
 (0)