Sitelet https://github.com/phpredis/phpredis/commit/525958ea
Skip to content

Commit 525958e

Browse files
Implement CONFIG REWRITE
Closes #847
1 parent 46e6427 commit 525958e

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎redis.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,8 +2729,10 @@ PHP_METHOD(Redis, config)
27292729
if (zend_string_equals_literal_ci(op, "GET") && key != NULL) {
27302730
cmd_len = REDIS_SPPRINTF(&cmd, "CONFIG", "SS", op, key);
27312731
cb = redis_mbulk_reply_zipped_raw;
2732-
} else if (zend_string_equals_literal_ci(op, "RESETSTAT")) {
2733-
cmd_len = REDIS_SPPRINTF(&cmd, "CONFIG", "s", ZEND_STRL("RESETSTAT"));
2732+
} else if (zend_string_equals_literal_ci(op, "RESETSTAT") ||
2733+
zend_string_equals_literal_ci(op, "REWRITE"))
2734+
{
2735+
cmd_len = REDIS_SPPRINTF(&cmd, "CONFIG", "s", ZSTR_VAL(op), ZSTR_LEN(op));
27342736
cb = redis_boolean_response;
27352737
} else if (zend_string_equals_literal_ci(op, "SET") && key != NULL && val != NULL) {
27362738
cmd_len = REDIS_SPPRINTF(&cmd, "CONFIG", "SSS", op, key, val);
@@ -2744,8 +2746,6 @@ PHP_METHOD(Redis, config)
27442746
cb(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
27452747
}
27462748
REDIS_PROCESS_RESPONSE(redis_boolean_response);
2747-
2748-
return;
27492749
}
27502750
/* }}} */
27512751

‎tests/RedisTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5561,6 +5561,15 @@ public function testConfig() {
55615561
$this->assertFalse($this->redis->config($cmd));
55625562
}
55635563
$this->assertFalse($this->redis->config('set', 'foo'));
5564+
5565+
/* REWRITE. We don't care if it actually works, just that the
5566+
command be attempted */
5567+
$res = $this->redis->config('rewrite');
5568+
$this->assertTrue(is_bool($res));
5569+
if ($res == false) {
5570+
$this->assertPatternMatch($this->redis->getLastError(), '/.*config.*/');
5571+
$this->redis->clearLastError();
5572+
}
55645573
}
55655574

55665575
public function testReconnectSelect() {

0 commit comments

Comments
 (0)