com php-src: Make session_cache_expire() arg an i nteger: ext/session/session.c ext/session/tests/session _cache_expire_error.phpt
| From: | Nikita Popov | Date: | Fri, 01 Feb 2019 15:08:31 +0000 |
| Subject: | com php-src: Make session_cache_expire() arg an i nteger: ext/session/session.c ext/session/tests/session _cache_expire_error.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104424@lists.php.net to get a copy of this message | ||
Commit: 4f187b8fbc4704b43c57de09ee68e4562910ec8e
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 1 Feb 2019 16:08:31 +0100
Parents: 4a4c68d90d8fac4c54932d356a156d000c9c684c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4f187b8fbc4704b43c57de09ee68e4562910ec8e
Log:
Make session_cache_expire() arg an integer
This is logically an integer, and the function also returns the old
value as an integer. The fact that the integer needs to be converted
to a string for the ini assignment is an implementation detail.
Changed paths:
M ext/session/session.c
M ext/session/tests/session_cache_expire_error.phpt
Diff:
diff --git a/ext/session/session.c b/ext/session/session.c
index 90e4a02..c38a855 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -2344,30 +2344,31 @@ static PHP_FUNCTION(session_cache_limiter)
Return the current cache expire. If new_cache_expire is given, the current cache_expire is
replaced with new_cache_expire */
static PHP_FUNCTION(session_cache_expire)
{
- zval *expires = NULL;
- zend_string *ini_name;
+ zend_long expires;
+ zend_bool expires_is_null = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &expires) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &expires, &expires_is_null) ==
FAILURE) {
return;
}
- if (expires && PS(session_status) == php_session_active) {
+ if (!expires_is_null && PS(session_status) == php_session_active) {
php_error_docref(NULL, E_WARNING, "Cannot change cache expire when session is active");
RETURN_LONG(PS(cache_expire));
}
- if (expires && SG(headers_sent)) {
+ if (!expires_is_null && SG(headers_sent)) {
php_error_docref(NULL, E_WARNING, "Cannot change cache expire when headers already
sent");
RETURN_FALSE;
}
RETVAL_LONG(PS(cache_expire));
- if (expires) {
- convert_to_string_ex(expires);
- ini_name = zend_string_init("session.cache_expire",
sizeof("session.cache_expire") - 1, 0);
- zend_alter_ini_entry(ini_name, Z_STR_P(expires), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
+ if (!expires_is_null) {
+ zend_string *ini_name = zend_string_init("session.cache_expire",
sizeof("session.cache_expire") - 1, 0);
+ zend_string *ini_value = zend_long_to_str(expires);
+ zend_alter_ini_entry(ini_name, ini_value, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
zend_string_release_ex(ini_name, 0);
+ zend_string_release_ex(ini_value, 0);
}
}
/* }}} */
diff --git a/ext/session/tests/session_cache_expire_error.phpt
b/ext/session/tests/session_cache_expire_error.phpt
index 5ae5d95..484d422 100644
--- a/ext/session/tests/session_cache_expire_error.phpt
+++ b/ext/session/tests/session_cache_expire_error.phpt
@@ -120,7 +120,7 @@ int(-10)
int(%s)
-- Iteration 9 --
-int(1)
+int(0)
-- Iteration 10 --
int(0)
@@ -141,22 +141,34 @@ int(0)
int(1)
-- Iteration 16 --
-int(0)
+
+Warning: session_cache_expire() expects parameter 1 to be int, string given in %s on line %d
+NULL
-- Iteration 17 --
-int(0)
+
+Warning: session_cache_expire() expects parameter 1 to be int, string given in %s on line %d
+NULL
-- Iteration 18 --
-int(0)
+
+Warning: session_cache_expire() expects parameter 1 to be int, string given in %s on line %d
+NULL
-- Iteration 19 --
-int(0)
+
+Warning: session_cache_expire() expects parameter 1 to be int, string given in %s on line %d
+NULL
-- Iteration 20 --
-int(0)
+
+Warning: session_cache_expire() expects parameter 1 to be int, string given in %s on line %d
+NULL
-- Iteration 21 --
-int(0)
+
+Warning: session_cache_expire() expects parameter 1 to be int, object given in %s on line %d
+NULL
-- Iteration 22 --
int(0)
@@ -165,5 +177,7 @@ int(0)
int(0)
-- Iteration 24 --
-int(0)
+
+Warning: session_cache_expire() expects parameter 1 to be int, resource given in %s on line %d
+NULL
Done