Skip to content

Commit

Permalink
Do not call session_start() on CLI processes
Browse files Browse the repository at this point in the history
This is a refinement of the idea in civicrm/civicrm-wordpress#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>
  • Loading branch information
totten authored and kcristiano committed Jul 15, 2020
1 parent 630e746 commit f7869f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion civicrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public function setup_instance() {
* 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();
}

Expand Down

0 comments on commit f7869f9

Please sign in to comment.