Skip to content

Commit 3094a79

Browse files
authored
Merge pull request #2452 from elcreator/fix/cli-headers-already-sent
fix(core): CLI cookie warning headers already sent
2 parents e5f104f + 0b48144 commit 3094a79

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎core/functions/session_proxy.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ public static function init(): void
5757
self::migrateLegacySessionIfNeeded($store);
5858

5959
// Start PHP session with cookies disabled (Laravel owns the cookie).
60-
if (session_status() === PHP_SESSION_NONE) {
60+
// Skipped on CLI: there are no headers to send there, and the merge
61+
// below fills $_SESSION either way. The CLI installer reaches this
62+
// after it has printed, so each call would only warn.
63+
if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_NONE) {
6164
ini_set('session.use_cookies', '0');
6265
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) {
6366
ini_set('session.use_only_cookies', '0');

‎index.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@
8282
if (IN_INSTALL_MODE) {
8383
// Set some settings, and address some IE issues.
8484
@ini_set('url_rewriter.tags', '');
85-
if (session_status() === PHP_SESSION_NONE) {
85+
// Browser-only session tweaks. The CLI installer includes this file after
86+
// it has already printed, so on CLI these only warn about sent headers.
87+
if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_NONE) {
8688
ini_set('session.use_trans_sid', 0);
8789
ini_set('session.use_only_cookies', 1);
8890
}

0 commit comments

Comments
 (0)