summaryrefslogtreecommitdiff
path: root/ext/session
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-07-26 13:20:48 +0200
committerAnatol Belski <ab@php.net>2017-07-26 13:20:48 +0200
commiteaf5c7cdd4267e4b31732500a464546a9eae5b88 (patch)
treed6086d0567e70199d018667d924a45645f02be86 /ext/session
parentbb9ea4e88b14ab9ae51370c6265d8a88c8532937 (diff)
parentbd00fe81cc4525b7d8e5c36a3844ee2254e5f69c (diff)
downloadphp-git-eaf5c7cdd4267e4b31732500a464546a9eae5b88.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fixed bug #74833, SID constant created with wrong module number
Diffstat (limited to 'ext/session')
-rw-r--r--ext/session/session.c7
-rw-r--r--ext/session/tests/bug74833.phpt22
2 files changed, 28 insertions, 1 deletions
diff --git a/ext/session/session.c b/ext/session/session.c
index d702d1b159..fa392dd3bc 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -99,6 +99,9 @@ zend_class_entry *php_session_update_timestamp_iface_entry;
static void php_session_send_cookie(void);
static void php_session_abort(void);
+/* Initialized in MINIT, readonly otherwise. */
+static int my_module_number = 0;
+
/* Dispatched by RINIT and by php_session_destroy */
static inline void php_rinit_session_globals(void) /* {{{ */
{
@@ -111,6 +114,7 @@ static inline void php_rinit_session_globals(void) /* {{{ */
PS(mod_user_is_open) = 0;
PS(define_sid) = 1;
PS(session_vars) = NULL;
+ PS(module_number) = my_module_number;
ZVAL_UNDEF(&PS(http_session_vars));
}
/* }}} */
@@ -2620,7 +2624,8 @@ static PHP_MINIT_FUNCTION(session) /* {{{ */
zend_register_auto_global(zend_string_init("_SESSION", sizeof("_SESSION") - 1, 1), 0, NULL);
- PS(module_number) = module_number; /* if we really need this var we need to init it in zts mode as well! */
+ my_module_number = module_number;
+ PS(module_number) = module_number;
PS(session_status) = php_session_none;
REGISTER_INI_ENTRIES();
diff --git a/ext/session/tests/bug74833.phpt b/ext/session/tests/bug74833.phpt
new file mode 100644
index 0000000000..5a0eda71f7
--- /dev/null
+++ b/ext/session/tests/bug74833.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #74833 Session module number is uninitialized when SID is reset
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+
+ob_start();
+
+session_start();
+session_regenerate_id();
+$c = get_defined_constants(true);
+/* Ensure the SID constant has correct module number. */
+var_dump(isset($c['session']['SID']));
+
+ob_end_flush();
+?>
+==DONE==
+--EXPECTF--
+bool(true)
+==DONE==
+