com php-src: Merge branch 'PHP-5.6': ext/session/session.c

From: Date: Tue, 03 Feb 2015 04:49:14 +0000
Subject: com php-src: Merge branch 'PHP-5.6': ext/session/session.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-84580@lists.php.net to get a copy of this message
Commit: 5afe554d329cc7ebf054a42cc1d9bc3cff3e1b9a Author: Yasuo Ohgaki <yohgaki@php.net> Tue, 3 Feb 2015 13:49:14 +0900 Parents: e93042998af1fea9204e17bc5cdd13c702156d5b 2983ef3c4822c089d1e3de463c12bd8437125d6c Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5afe554d329cc7ebf054a42cc1d9bc3cff3e1b9a Log: Merge branch 'PHP-5.6' * PHP-5.6: Fixed bug #68063 Empty session IDs do still start sessions Conflicts: ext/session/session.c ext/session/tests/bug61470.phpt Bugs: https://bugs.php.net/68063 https://bugs.php.net/61470 Changed paths: MM ext/session/session.c Diff: diff --cc ext/session/session.c index 553f1ed,dfe5a4d..c6f5f52 --- a/ext/session/session.c +++ b/ext/session/session.c @@@ -2175,61 -2068,17 +2175,66 @@@ static PHP_FUNCTION(session_decode } /* }}} */ -/* {{{ proto bool session_start(void) - Begin session - reinitializes freezed variables, registers browsers etc */ +static int php_session_start_set_ini(zend_string *varname, zend_string *new_value) { + int ret; + smart_str buf ={0}; + smart_str_appends(&buf, "session"); + smart_str_appendc(&buf, '.'); + smart_str_append(&buf, varname); + smart_str_0(&buf); + ret = zend_alter_ini_entry_ex(buf.s, new_value, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0); + smart_str_free(&buf); + return ret; +} + +/* {{{ proto bool session_start([array options]) ++ Begin session */ static PHP_FUNCTION(session_start) { - /* skipping check for non-zero args for performance reasons here ?*/ - if (PS(id) && !strlen(PS(id))) { + zval *options = NULL; + zval *value; + zend_ulong num_idx; + zend_string *str_idx; + int read_and_close = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|a", &options) == FAILURE) { + RETURN_FALSE; + } + ++ if (PS(id) && !(PS(id)->len)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot start session with empty session ID"); + RETURN_FALSE; + } + - php_session_start(TSRMLS_C); + /* set options */ + if (options) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(options), num_idx, str_idx, value) { + if (str_idx) { + switch(Z_TYPE_P(value)) { + case IS_STRING: + case IS_TRUE: + case IS_FALSE: + case IS_LONG: + if (zend_string_equals_literal(str_idx, "read_and_close")) { + read_and_close = zval_get_long(value); + } else { + zend_string *val = zval_get_string(value); + if (php_session_start_set_ini(str_idx, val) == FAILURE) { + php_error_docref(NULL, E_WARNING, "Setting option '%s' failed", str_idx->val); + } + zend_string_release(val); + } + break; + default: + php_error_docref(NULL, E_WARNING, "Option(%s) value must be string, boolean or long", str_idx->val); + break; + } + } + (void) num_idx; + } ZEND_HASH_FOREACH_END(); + } + + php_session_start(); if (PS(session_status) != php_session_active) { RETURN_FALSE;

« previous php.cvs (#84580) next »