-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relax requirements on set's expire argument #1830
Conversation
redis_commands.c
Outdated
} else if (z_opts && Z_TYPE_P(z_opts) == IS_LONG) { | ||
expire = Z_LVAL_P(z_opts); | ||
} else if (z_opts && Z_TYPE_P(z_opts) != IS_NULL) { | ||
if (Z_TYPE_P(z_opts) != IS_LONG && Z_TYPE_P(z_opts) != IS_STRING) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need add check for IS_DOUBLE
and additional check is_numeric_string
for IS_STRING
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, we should accept IS_DOUBLE
zval
s as well.
I'm not sure how much is_numeric_string
gets us because I believe non-strings will resolve to 0
which will fail before sending the command because I verify that the TTL
is greater than zero.
I suppose it would let us be even more specific about the error but I'm not sure it's worth the extra logic.
@yatsukhnenko Does the latest change look good to you? |
@michael-grunder I want to check how it will work with non-numeric strings |
What happens is that a non-numeric string (e.g. 'foo') converts to <?php
$obj_r = new Redis();
$obj_r->connect('localhost', 6379);
var_dump($obj_r->set('foo', 'bar', 'notastring'));
?>
I suppose there is a risk of doing something like this: $obj_r->set('foo', 'bar', '12345notastring');
?> I don't mind also using |
I worried about strings like that |
Merged, but now that I look at the code I think I should probably also use |
See: #1783