summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Morozov <morozov@tut.by>2017-07-19 17:13:34 +0300
committerJoe Watkins <krakjoe@php.net>2017-07-20 07:52:02 +0100
commit9b9184a45a015a69d39fe88eebd93e14b575afc4 (patch)
treed3002f7cbee0af6b0525a61c0184c92ee9633fff
parent18595b6fc6378c73a1c8c382081c527db5141964 (diff)
downloadphp-git-9b9184a45a015a69d39fe88eebd93e14b575afc4.tar.gz
Fixed bug #74941 - Session fails to start after having headers sent
-rw-r--r--NEWS2
-rw-r--r--ext/session/session.c4
-rw-r--r--ext/session/tests/bug74941.phpt22
3 files changed, 26 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index a1a9b4e334..2256e9b369 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ PHP NEWS
with "#"). (Andrew Nester)
. Fixed bug #74936 (session_cache_expire/cache_limiter/save_path() trigger a
warning in read mode). (morozov)
+ . Fixed bug #74941 (session fails to start after having headers sent).
+ (morozov)
- SPL:
. Fixed bug #74669 (Unserialize ArrayIterator broken). (Andrew Nester)
diff --git a/ext/session/session.c b/ext/session/session.c
index 1e8321d1ac..f359c1faf9 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -2035,7 +2035,7 @@ static PHP_FUNCTION(session_id)
return;
}
- if (name && SG(headers_sent)) {
+ if (name && PS(use_cookies) && SG(headers_sent)) {
php_error_docref(NULL, E_WARNING, "Cannot change session id when headers already sent");
RETURN_FALSE;
}
@@ -2356,7 +2356,7 @@ static PHP_FUNCTION(session_start)
* required. i.e. There shouldn't be any outputs in output buffer, otherwise session
* module is unable to rewrite output.
*/
- if (SG(headers_sent)) {
+ if (PS(use_cookies) && SG(headers_sent)) {
php_error_docref(NULL, E_WARNING, "Cannot start session when headers already sent");
RETURN_FALSE;
}
diff --git a/ext/session/tests/bug74941.phpt b/ext/session/tests/bug74941.phpt
new file mode 100644
index 0000000000..953d642b10
--- /dev/null
+++ b/ext/session/tests/bug74941.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #74941 session_start() triggers a warning after headers have been sent but cookies are not used
+--SKIPIF--
+<?php
+include('skipif.inc');
+?>
+--FILE--
+<?php
+
+ini_set('session.use_cookies', false);
+ini_set('session.cache_limiter', false);
+
+echo ".\n";
+
+session_id('BUG74941');
+var_dump(session_start());
+?>
+===DONE===
+--EXPECT--
+.
+bool(true)
+===DONE===