summaryrefslogtreecommitdiff
path: root/ext/session/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/session/session.c')
-rw-r--r--ext/session/session.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/ext/session/session.c b/ext/session/session.c
index 671968e8da..aa10028989 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -2353,33 +2353,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) {
- if (!try_convert_to_string(expires)) {
- return;
- }
-
- 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);
}
}
/* }}} */