com php-src: Fixed bug #74941 - Session fails to start after having headers sent: NEWS ext/session/session.c ext/session/tests/bug74941.phpt
| From: | Joe Watkins | Date: | Thu, 20 Jul 2017 06:52:02 +0000 |
| Subject: | com php-src: Fixed bug #74941 - Session fails to start after having headers sent: NEWS ext/session/session.c ext/session/tests/bug74941.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98652@lists.php.net to get a copy of this message | ||
Commit: 9b9184a45a015a69d39fe88eebd93e14b575afc4
Author: Sergei Morozov <morozov@tut.by> Wed, 19 Jul 2017 17:13:34 +0300
Committer: Joe Watkins <krakjoe@php.net> Thu, 20 Jul 2017 07:52:02 +0100
Parents: 18595b6fc6378c73a1c8c382081c527db5141964
Branches: PHP-7.2
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9b9184a45a015a69d39fe88eebd93e14b575afc4
Log:
Fixed bug #74941 - Session fails to start after having headers sent
Bugs:
https://bugs.php.net/74941
Changed paths:
M NEWS
M ext/session/session.c
A ext/session/tests/bug74941.phpt
Diff:
diff --git a/NEWS b/NEWS
index a1a9b4e..2256e9b 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 1e8321d..f359c1f 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 0000000..953d642
--- /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===