-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not start session when running under WP-CLI #135
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
totten
added a commit
to totten/civicrm-wordpress
that referenced
this pull request
Jul 3, 2020
This is a refinement of the idea in civicrm#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: ``` PHP Warning: session_start(): Cannot send session cookie - headers already sent by (output started at phar:///Users/totten/bknix/bin/cv/.box/src/Printer.php:83) in /Users/totten/bknix/build/wpmaster/web/wp-content/plugins/civicrm/civicrm.php on line 371 PHP Stack trace: PHP 1. {main}() /Users/totten/bknix/bin/cv:0 PHP 2. require() /Users/totten/bknix/bin/cv:14 PHP 3. Civi\Cv\Application::main() phar:///Users/totten/bknix/bin/cv/bin/cv:27 PHP 4. Civi\Cv\Application->run() phar:///Users/totten/bknix/bin/cv/src/Application.php:15 PHP 5. Civi\Cv\Application->doRun() phar:///Users/totten/bknix/bin/cv/vendor/symfony/console/Application.php:124 PHP 6. Civi\Cv\Application->doRun() phar:///Users/totten/bknix/bin/cv/src/Application.php:46 PHP 7. Civi\Cv\Application->doRunCommand() phar:///Users/totten/bknix/bin/cv/vendor/symfony/console/Application.php:193 PHP 8. Civi\Cv\Command\UpgradeDbCommand->run() phar:///Users/totten/bknix/bin/cv/vendor/symfony/console/Application.php:850 PHP 9. Civi\Cv\Command\UpgradeDbCommand->execute() phar:///Users/totten/bknix/bin/cv/vendor/symfony/console/Command/Command.php:257 PHP 10. Civi\Cv\Command\UpgradeDbCommand->boot() phar:///Users/totten/bknix/bin/cv/src/Command/UpgradeDbCommand.php:39 PHP 11. call_user_func:{phar:///Users/totten/bknix/bin/cv/src/Util/BootTrait.php:39}() phar:///Users/totten/bknix/bin/cv/src/Util/BootTrait.php:39 PHP 12. Civi\Cv\Command\UpgradeDbCommand->_boot_full() phar:///Users/totten/bknix/bin/cv/src/Util/BootTrait.php:39 PHP 13. CRM_Utils_System::loadBootStrap() phar:///Users/totten/bknix/bin/cv/src/Util/BootTrait.php:99 PHP 14. CRM_Utils_System_WordPress->loadBootStrap() /Users/totten/bknix/build/wpmaster/web/wp-content/plugins/civicrm/civicrm/CRM/Utils/System.php:1521 PHP 15. require_once() /Users/totten/bknix/build/wpmaster/web/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/WordPress.php:600 PHP 16. require_once() /Users/totten/bknix/build/wpmaster/web/wp-load.php:37 PHP 17. require_once() /Users/totten/bknix/build/wpmaster/web/wp-config.php:97 PHP 18. do_action() /Users/totten/bknix/build/wpmaster/web/wp-settings.php:392 PHP 19. WP_Hook->do_action() /Users/totten/bknix/build/wpmaster/web/wp-includes/plugin.php:478 PHP 20. WP_Hook->apply_filters() /Users/totten/bknix/build/wpmaster/web/wp-includes/class-wp-hook.php:312 PHP 21. CiviCRM_For_WordPress->setup_instance() /Users/totten/bknix/build/wpmaster/web/wp-includes/class-wp-hook.php:288 PHP 22. session_start() /Users/totten/bknix/build/wpmaster/web/wp-content/plugins/civicrm/civicrm.php:371 ``` After ----- It doesn't try to start session in CLI (where sessions don't make sense).
kcristiano
pushed a commit
to tadpolecc/civicrm
that referenced
this pull request
Jul 3, 2020
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>
kcristiano
pushed a commit
to tadpolecc/civicrm
that referenced
this pull request
Jul 3, 2020
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>
kcristiano
pushed a commit
to tadpolecc/civicrm
that referenced
this pull request
Jul 10, 2020
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>
kcristiano
pushed a commit
to tadpolecc/civicrm
that referenced
this pull request
Jul 15, 2020
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>
bastienho
pushed a commit
to bastienho/civicrm-wordpress
that referenced
this pull request
Sep 10, 2020
This is a refinement of the idea in civicrm#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: ``` PHP Warning: session_start(): Cannot send session cookie - headers already sent by (output started at phar:///Users/totten/bknix/bin/cv/.box/src/Printer.php:83) in /Users/totten/bknix/build/wpmaster/web/wp-content/plugins/civicrm/civicrm.php on line 371 PHP Stack trace: PHP 1. {main}() /Users/totten/bknix/bin/cv:0 PHP 2. require() /Users/totten/bknix/bin/cv:14 PHP 3. Civi\Cv\Application::main() phar:///Users/totten/bknix/bin/cv/bin/cv:27 PHP 4. Civi\Cv\Application->run() phar:///Users/totten/bknix/bin/cv/src/Application.php:15 PHP 5. Civi\Cv\Application->doRun() phar:///Users/totten/bknix/bin/cv/vendor/symfony/console/Application.php:124 PHP 6. Civi\Cv\Application->doRun() phar:///Users/totten/bknix/bin/cv/src/Application.php:46 PHP 7. Civi\Cv\Application->doRunCommand() phar:///Users/totten/bknix/bin/cv/vendor/symfony/console/Application.php:193 PHP 8. Civi\Cv\Command\UpgradeDbCommand->run() phar:///Users/totten/bknix/bin/cv/vendor/symfony/console/Application.php:850 PHP 9. Civi\Cv\Command\UpgradeDbCommand->execute() phar:///Users/totten/bknix/bin/cv/vendor/symfony/console/Command/Command.php:257 PHP 10. Civi\Cv\Command\UpgradeDbCommand->boot() phar:///Users/totten/bknix/bin/cv/src/Command/UpgradeDbCommand.php:39 PHP 11. call_user_func:{phar:///Users/totten/bknix/bin/cv/src/Util/BootTrait.php:39}() phar:///Users/totten/bknix/bin/cv/src/Util/BootTrait.php:39 PHP 12. Civi\Cv\Command\UpgradeDbCommand->_boot_full() phar:///Users/totten/bknix/bin/cv/src/Util/BootTrait.php:39 PHP 13. CRM_Utils_System::loadBootStrap() phar:///Users/totten/bknix/bin/cv/src/Util/BootTrait.php:99 PHP 14. CRM_Utils_System_WordPress->loadBootStrap() /Users/totten/bknix/build/wpmaster/web/wp-content/plugins/civicrm/civicrm/CRM/Utils/System.php:1521 PHP 15. require_once() /Users/totten/bknix/build/wpmaster/web/wp-content/plugins/civicrm/civicrm/CRM/Utils/System/WordPress.php:600 PHP 16. require_once() /Users/totten/bknix/build/wpmaster/web/wp-load.php:37 PHP 17. require_once() /Users/totten/bknix/build/wpmaster/web/wp-config.php:97 PHP 18. do_action() /Users/totten/bknix/build/wpmaster/web/wp-settings.php:392 PHP 19. WP_Hook->do_action() /Users/totten/bknix/build/wpmaster/web/wp-includes/plugin.php:478 PHP 20. WP_Hook->apply_filters() /Users/totten/bknix/build/wpmaster/web/wp-includes/class-wp-hook.php:312 PHP 21. CiviCRM_For_WordPress->setup_instance() /Users/totten/bknix/build/wpmaster/web/wp-includes/class-wp-hook.php:288 PHP 22. session_start() /Users/totten/bknix/build/wpmaster/web/wp-content/plugins/civicrm/civicrm.php:371 ``` After ----- It doesn't try to start session in CLI (where sessions don't make sense).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Prevents PHP warnings by skipping
session_start()
when running via WP-CLI.Before
When running WP-CLI, there are situations where the Apache user has permissions that the Shell user does not, which can result in the following warnings:
Please note that the above is in the context of CiviCRM running via Memcached, but the ability to write to
session.save_path
is common to all contexts.After
No PHP warnings:
Technical Details
Tests for WP-CLI and skips
session_start()
when detected.