Skip to content

Commit fe02d5d

Browse files
Removed unused code and updated unit tests to use === comparison instead of ==. In addition, removed string conversion conditional as per Nicolasff
1 parent 6a53379 commit fe02d5d

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

redis.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5562,7 +5562,6 @@ PHP_METHOD(Redis, object)
55625562
RedisSock *redis_sock;
55635563
char *cmd = "", *info = NULL, *key = NULL;
55645564
int cmd_len, info_len, key_len;
5565-
//long port = 6379;
55665565

55675566
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss",
55685567
&object, redis_ce, &info, &info_len, &key, &key_len) == FAILURE) {
@@ -5883,10 +5882,8 @@ redis_build_script_exists_cmd(char **ret, zval **argv, int argc) {
58835882

58845883
// Iterate our arguments
58855884
for(i=0;i<argc;i++) {
5886-
// If the argument isn't a string, convert it
5887-
if(Z_TYPE_P(argv[i]) != IS_STRING) {
5888-
convert_to_string(argv[i]);
5889-
}
5885+
// Convert our argument to a string if we need to
5886+
convert_to_string(argv[i]);
58905887

58915888
// Append this script sha to our SCRIPT EXISTS command
58925889
cmd_len = redis_cmd_append_str(ret, cmd_len, Z_STRVAL_P(argv[i]), Z_STRLEN_P(argv[i]));
@@ -5947,7 +5944,6 @@ PHP_METHOD(Redis, script) {
59475944
} else {
59485945
// Unknown directive
59495946
efree(z_args);
5950-
zend_throw_exception(redis_exception_ce, "Unknown SCRIPT sub command", 0 TSRMLS_CC);
59515947
RETURN_FALSE;
59525948
}
59535949

@@ -5992,10 +5988,8 @@ PHP_METHOD(Redis, dump) {
59925988
REDIS_PROCESS_REQUEST(redis_sock, cmd, cmd_len);
59935989
IF_ATOMIC() {
59945990
redis_ping_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
5995-
//redis_string_response(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, NULL, NULL);
59965991
}
59975992
REDIS_PROCESS_RESPONSE(redis_ping_response);
5998-
//REDIS_PROCESS_RESPONSE(redis_string_response);
59995993
}
60005994

60015995
/*
@@ -6112,7 +6106,7 @@ PHP_METHOD(Redis, getLastError) {
61126106

61136107
// Return our last error or NULL if we don't have one
61146108
if(redis_sock->err != NULL && redis_sock->err_len > 0) {
6115-
RETURN_STRING(redis_sock->err, 1);
6109+
RETURN_STRINGL(redis_sock->err, redis_sock->err_len, 1);
61166110
} else {
61176111
RETURN_NULL();
61186112
}

tests/TestRedis.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,16 +2903,16 @@ public function testDumpRestore() {
29032903
$this->assertTrue($this->redis->restore('bar', 0, $d_foo));
29042904

29052905
// Now check that the keys have switched
2906-
$this->assertTrue($this->redis->get('foo') == 'this-is-bar');
2907-
$this->assertTrue($this->redis->get('bar') == 'this-is-foo');
2906+
$this->assertTrue($this->redis->get('foo') === 'this-is-bar');
2907+
$this->assertTrue($this->redis->get('bar') === 'this-is-foo');
29082908

29092909
$this->redis->del('foo');
29102910
$this->redis->del('bar');
29112911
}
29122912

29132913
public function testGetLastError() {
29142914
// We shouldn't have any errors now
2915-
$this->assertTrue($this->redis->getLastError() == NULL);
2915+
$this->assertTrue($this->redis->getLastError() === NULL);
29162916

29172917
// Throw some invalid lua at redis
29182918
$this->redis->eval("not-a-lua-script");
@@ -3099,9 +3099,9 @@ public function testEvalSHA() {
30993099
$sha = sha1($scr);
31003100

31013101
// Run it when it doesn't exist, run it with eval, and then run it with sha1
3102-
$this->assertTrue(false == $this->redis->evalsha($scr));
3103-
$this->assertTrue(1 == $this->redis->eval($scr));
3104-
$this->assertTrue(1 == $this->redis->evalsha($sha));
3102+
$this->assertTrue(false === $this->redis->evalsha($scr));
3103+
$this->assertTrue(1 === $this->redis->eval($scr));
3104+
$this->assertTrue(1 === $this->redis->evalsha($sha));
31053105
}
31063106

31073107
public function testUnserialize() {

0 commit comments

Comments
 (0)