From 0b48144a7bbe6d6d7bb566b0a685c2038c0031dc Mon Sep 17 00:00:00 2001 From: Artur Kyryliuk Date: Wed, 9 Sep 2026 18:33:35 +0200 Subject: [PATCH] fix(core): CLI cookie warning headers already sent The CLI installer includes index.php after it has already printed, so PHP considers the headers sent by the time the session settings are applied. Every CLI install therefore emitted four warnings: Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in index.php on line 86 Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in core/functions/session_proxy.php on line 61 Warning: session_id(): Session ID cannot be changed after headers have already been sent in core/functions/session_proxy.php on line 67 All of them address cookies and headers, which do not exist on CLI. Skip them there; $_SESSION is still filled by the merge that follows in EvoSessionProxy::init(), so nothing else changes. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01RYzFvo3wBzPhLzhG4Dkzk2 --- core/functions/session_proxy.php | 5 ++++- index.php | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/functions/session_proxy.php b/core/functions/session_proxy.php index 67434c8139..14b16d9a53 100644 --- a/core/functions/session_proxy.php +++ b/core/functions/session_proxy.php @@ -57,7 +57,10 @@ public static function init(): void self::migrateLegacySessionIfNeeded($store); // Start PHP session with cookies disabled (Laravel owns the cookie). - if (session_status() === PHP_SESSION_NONE) { + // Skipped on CLI: there are no headers to send there, and the merge + // below fills $_SESSION either way. The CLI installer reaches this + // after it has printed, so each call would only warn. + if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_NONE) { ini_set('session.use_cookies', '0'); if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 80400) { ini_set('session.use_only_cookies', '0'); diff --git a/index.php b/index.php index 7a9ec39ecd..acf3a7f105 100644 --- a/index.php +++ b/index.php @@ -82,7 +82,9 @@ if (IN_INSTALL_MODE) { // Set some settings, and address some IE issues. @ini_set('url_rewriter.tags', ''); - if (session_status() === PHP_SESSION_NONE) { + // Browser-only session tweaks. The CLI installer includes this file after + // it has already printed, so on CLI these only warn about sent headers. + if (PHP_SAPI !== 'cli' && session_status() === PHP_SESSION_NONE) { ini_set('session.use_trans_sid', 0); ini_set('session.use_only_cookies', 1); }