0

I'm trying to use the wp command on my server, but am getting these warnings every time I run it (wp will actually work, but it's very vocal about the warnings):

When running the command:

myuser@serverhtml$ wp

PHP Warning:  session_start(): open(/var/lib/php/session/sess_6r7oiur5t1lhsokahj590d1aa7, O_RDWR) failed: Permission denied (13) in /home/int/myuser/html/wp-content/plugins/wp-cassify/classes/wp_cassify_plugin.php on line 201
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/wp:0
PHP   2. include() /usr/local/bin/wp:4
PHP   3. include() phar:///usr/local/bin/wp/php/boot-phar.php:8
PHP   4. WP_CLI\bootstrap() phar:///usr/local/bin/wp/php/wp-cli.php:23
PHP   5. WP_CLI\Bootstrap\LaunchRunner->process() phar:///usr/local/bin/wp/php/bootstrap.php:75
PHP   6. WP_CLI\Runner->start() phar:///usr/local/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php:23
PHP   7. WP_CLI\Runner->load_wordpress() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1100
PHP   8. require() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1174
PHP   9. do_action() /home/int/myuser/html/wp-settings.php:450
PHP  10. WP_Hook->do_action() /home/int/myuser/html/wp-includes/plugin.php:453
PHP  11. WP_Hook->apply_filters() /home/int/myuser/html/wp-includes/class-wp-hook.php:310
PHP  12. call_user_func_array() /home/int/myuser/html/wp-includes/class-wp-hook.php:286
PHP  13. wp_cassify\WP_Cassify_Plugin->wp_cassify_session_start() /home/int/myuser/html/wp-includes/class-wp-hook.php:286
PHP  14. session_start() /home/int/myuser/html/wp-content/plugins/wp-cassify/classes/wp_cassify_plugin.php:201
PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /home/int/myuser/html/wp-content/themes/mytheme/functions.php:627) in /home/int/myuser/html/wp-content/plugins/wp-cassify/classes/wp_cassify_plugin.php on line 201
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/wp:0
PHP   2. include() /usr/local/bin/wp:4
PHP   3. include() phar:///usr/local/bin/wp/php/boot-phar.php:8
PHP   4. WP_CLI\bootstrap() phar:///usr/local/bin/wp/php/wp-cli.php:23
PHP   5. WP_CLI\Bootstrap\LaunchRunner->process() phar:///usr/local/bin/wp/php/bootstrap.php:75
PHP   6. WP_CLI\Runner->start() phar:///usr/local/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php:23
PHP   7. WP_CLI\Runner->load_wordpress() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1100
PHP   8. require() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1174
PHP   9. do_action() /home/int/myuser/html/wp-settings.php:450
PHP  10. WP_Hook->do_action() /home/int/myuser/html/wp-includes/plugin.php:453
PHP  11. WP_Hook->apply_filters() /home/int/myuser/html/wp-includes/class-wp-hook.php:310
PHP  12. call_user_func_array() /home/int/myuser/html/wp-includes/class-wp-hook.php:286
PHP  13. wp_cassify\WP_Cassify_Plugin->wp_cassify_session_start() /home/int/myuser/html/wp-includes/class-wp-hook.php:286
PHP  14. session_start() /home/int/myuser/html/wp-content/plugins/wp-cassify/classes/wp_cassify_plugin.php:201
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /home/int/myuser/html/wp-content/themes/mytheme/functions.php:627) in /home/int/myuser/html/wp-content/plugins/wp-cassify/classes/wp_cassify_plugin.php on line 201
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/wp:0
PHP   2. include() /usr/local/bin/wp:4
PHP   3. include() phar:///usr/local/bin/wp/php/boot-phar.php:8
PHP   4. WP_CLI\bootstrap() phar:///usr/local/bin/wp/php/wp-cli.php:23
PHP   5. WP_CLI\Bootstrap\LaunchRunner->process() phar:///usr/local/bin/wp/php/bootstrap.php:75
PHP   6. WP_CLI\Runner->start() phar:///usr/local/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php:23
PHP   7. WP_CLI\Runner->load_wordpress() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1100
PHP   8. require() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1174
PHP   9. do_action() /home/int/myuser/html/wp-settings.php:450
PHP  10. WP_Hook->do_action() /home/int/myuser/html/wp-includes/plugin.php:453
PHP  11. WP_Hook->apply_filters() /home/int/myuser/html/wp-includes/class-wp-hook.php:310
PHP  12. call_user_func_array() /home/int/myuser/html/wp-includes/class-wp-hook.php:286
PHP  13. wp_cassify\WP_Cassify_Plugin->wp_cassify_session_start() /home/int/myuser/html/wp-includes/class-wp-hook.php:286
PHP  14. session_start() /home/int/myuser/html/wp-content/plugins/wp-cassify/classes/wp_cassify_plugin.php:201
PHP Warning:  Unknown: open(/var/lib/php/session/sess_6r7oiur5t1lhsokahj590d1aa7, O_RDWR) failed: Permission denied (13) in Unknown on line 0
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/wp:0
PHP   2. include() /usr/local/bin/wp:4
PHP   3. include() phar:///usr/local/bin/wp/php/boot-phar.php:8
PHP   4. WP_CLI\bootstrap() phar:///usr/local/bin/wp/php/wp-cli.php:23
PHP   5. WP_CLI\Bootstrap\LaunchRunner->process() phar:///usr/local/bin/wp/php/bootstrap.php:75
PHP   6. WP_CLI\Runner->start() phar:///usr/local/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php:23
PHP   7. WP_CLI\Runner->_run_command_and_exit() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1102
PHP   8. WP_CLI\Runner->run_command() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:376
PHP   9. WP_CLI\Dispatcher\Subcommand->invoke() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:353
PHP  10. call_user_func() phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php:425
PHP  11. WP_CLI\Dispatcher\{closure}() phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php:425
PHP  12. call_user_func() phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php:89
PHP  13. Help_Command->__invoke() phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php:89
PHP Warning:  Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/session) in Unknown on line 0
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/wp:0
PHP   2. include() /usr/local/bin/wp:4
PHP   3. include() phar:///usr/local/bin/wp/php/boot-phar.php:8
PHP   4. WP_CLI\bootstrap() phar:///usr/local/bin/wp/php/wp-cli.php:23
PHP   5. WP_CLI\Bootstrap\LaunchRunner->process() phar:///usr/local/bin/wp/php/bootstrap.php:75
PHP   6. WP_CLI\Runner->start() phar:///usr/local/bin/wp/php/WP_CLI/Bootstrap/LaunchRunner.php:23
PHP   7. WP_CLI\Runner->_run_command_and_exit() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:1102
PHP   8. WP_CLI\Runner->run_command() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:376
PHP   9. WP_CLI\Dispatcher\Subcommand->invoke() phar:///usr/local/bin/wp/php/WP_CLI/Runner.php:353
PHP  10. call_user_func() phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php:425
PHP  11. WP_CLI\Dispatcher\{closure}() phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php:425
PHP  12. call_user_func() phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php:89
PHP  13. Help_Command->__invoke() phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php:89

Problem seems to be with my wp-cassify plugin (https://github.com/CGCookie/wp-cassify) and its use of the session_start function, but not quite knowledgeable enough to know where to go from here.

skippr
  • 2,656
  • 3
  • 24
  • 39
  • check https://stackoverflow.com/a/18542272/32763 basically session_start() should only be used once per request. If your script includes others via include/require/use ...and those also start a session you will get a warning. – Loopo Feb 15 '18 at 22:13
  • @Loopo no go. even with the wrapper, the warnings are thrown. If I just completely remove the `session_start` though, the warnings go away. – skippr Feb 16 '18 at 16:02
  • Try to give the read and write permission to your user for the folder `/var/lib/php/session/` . or, if you can, execute the command with an user that already has them – Luca Rainone Feb 20 '18 at 16:59
  • @LucaRainone this a shared-hosting server, so I don't have the ability to do that. Is there perhaps some way I can specify where it saves sessions to (i.e. a folder in my user's directory)? – skippr Feb 20 '18 at 21:47
  • @skippr try here http://php.net/manual/en/function.session-save-path.php – Luca Rainone Feb 20 '18 at 21:53

4 Answers4

0

It looks like the session handler has already been started by Wordpress when the plugin is initialized. Because of this, PHP prints a warning.

You can modify the plugin to wrap the session_start call in a test as suggested Loopo. It should be in the file /home/int/myuser/html/wp-content/plugins/wp-cassify/classes/wp_cassify_plugin.php at line 201.

All other errors should go away with this fix. (I suspect the permission denied error to be raised because the file is opened twice because session_start is called twice).

MRousse
  • 526
  • 1
  • 4
  • 9
  • As stated to Loopo, no go. Even with the wrapper (which the code already has, and I tried the `PHP <5.4.0` versions of the wrapper as well) the warnings are still thrown. If I comment out the `session_start` though, the warnings go away. – skippr Feb 16 '18 at 16:03
0

You don't appear to have write permission to the /var/lib/php/session/sess_6r7oiur5t1lhsokahj590d1aa7 file on your server, you can work around it. if you have access to the system files of server you can make this files writable or if you don't have access to this folder you can change session directory. Before the call to session_start() put in a call to session_save_path() and give it the name of a directory writable by the server. for more detailed you can see here

Vel
  • 9,027
  • 6
  • 34
  • 66
Armen Grigoryan
  • 521
  • 2
  • 9
  • This seems like a viable solution, but requires me modifying the contents of a plugin which will be overwritten every time I update it. I'm working with my sysadmins to see if I can find a solution on their end, given this is a shared server. – skippr Feb 22 '18 at 21:25
0

Have you tried uninstalling wp-cli and reinstalling in a new location? I had problems running the wp command at first whenever I was on shared hosting. Each time I had to write an alias. But, I eventually reinstalled into a bin directory where I had different permissions and things worked better.

0

Solution ended up being to add:

ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../session')); 

inside of wp-config.php.

skippr
  • 2,656
  • 3
  • 24
  • 39
  • https://www.screencast.com/t/48k8SBslR5 the solution was in my answer, I have left link, if you had click on it you would found this answer http://php.net/manual/en/function.session-save-path.php – Armen Grigoryan Feb 26 '18 at 12:20
  • hrm, not sure how i missed that. hard to see links on here lol, but im willing to give it to you. post that line in your answer, and i'll mark yours as the answer – skippr Feb 26 '18 at 16:24