From 18126344f9e23398f57c66a46d549cddc16d0b10 Mon Sep 17 00:00:00 2001 From: Tim Otten <totten@civicrm.org> Date: Thu, 2 Jul 2020 21:36:26 -0700 Subject: [PATCH] Do not call session_start() on CLI processes This is a refinement of the idea in https://github.com/civicrm/civicrm-wordpress/pull/135 to address other CLI use-cases. Before ------- If I have a `wpmaster` site on on `bknix-max` (php73), and if I run `cv upgrade:db -vv`, then there are several warnings like this: After ----- It doesn't try to start session in CLI (where sessions don't make sense). Signed-off-by: Kevin Cristiano <kcristiano@kcristiano.com> --- civicrm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/civicrm.php b/civicrm.php index a419c69f95..4a839c9fb1 100644 --- a/civicrm.php +++ b/civicrm.php @@ -367,7 +367,7 @@ class CiviCRM_For_WordPress { * There is no session handling in WP - hence we start it for CiviCRM pages * except when running via WP-CLI which does not require sessions. */ - if ( empty( $session_id ) && ! ( defined( 'WP_CLI' ) && WP_CLI ) ) { + if ( empty( $session_id ) && ! ( defined( 'WP_CLI' ) && WP_CLI ) && ( PHP_SAPI !== 'cli' ) ) { session_start(); } -- GitLab