Skip to content
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

Logger crashes if unable to write #8

Closed
patrick-leb opened this issue Jul 29, 2021 · 2 comments
Closed

Logger crashes if unable to write #8

patrick-leb opened this issue Jul 29, 2021 · 2 comments

Comments

@patrick-leb
Copy link

patrick-leb commented Jul 29, 2021

When attempting to use WP-CLI , the command line crashes because it's unable to write the file.
It would probably need a try/catch or another logging location.

# sudo -u wpcli wp redis flush
PHP Fatal error:  Uncaught RuntimeException: The file could not be written to. Check that appropriate permissions have been set. in /var/www/html/wordpress/web/app/plugins/bh-wc-checkout-rate-limiter/strauss/katzgrau/klogger/src/Logger.php:134
Stack trace:
#0 /var/www/html/wordpress/web/app/plugins/bh-wc-checkout-rate-limiter/strauss/brianhenryie/wp-logger/src/includes/class-bh-wp-logger.php(140): BrianHenryIE\Checkout_Rate_Limiter\Katzgrau\KLogger\Logger->__construct()
#1 /var/www/html/wordpress/web/app/plugins/bh-wc-checkout-rate-limiter/strauss/brianhenryie/wp-logger/src/class-logger.php(23): BrianHenryIE\Checkout_Rate_Limiter\BrianHenryIE\WP_Logger\includes\BH_WP_Logger->__construct()
#2 /var/www/html/wordpress/web/app/plugins/bh-wc-checkout-rate-limiter/strauss/brianhenryie/wp-logger/src/class-logger.php(40): BrianHenryIE\Checkout_Rate_Limiter\BrianHenryIE\WP_Logger\Logger->__construct()
#3 /var/www/html/wordpress/web/app/plugins/bh-wc-checkout-rate-limiter/bh-wc-checkout-rate-limiter.php(64): BrianHenryIE\Checkout_Rate_L in /var/www/html/wordpress/web/app/plugins/bh-wc-checkout-rate-limiter/strauss/katzgrau/klogger/src/Logger.php on line 134
@BrianHenryIE
Copy link
Owner

BrianHenryIE commented Jul 31, 2021

Hey, thanks.

I've changed it so it uses the native WooCommerce logger now (rather than KLogger), so hopefully that won't be a problem anymore. It was mostly tests in this repo and in the logger repo.

Am I correct to understand that it was working ok as a regular plugin, but only causing a problem when you ran a (unrelated) CLI command?

I should, as you say, try/catch around that, then add an admin notice ~"chmod /path/to...", but I'm surprised this is a CLI issue and not a general issue. I guess CLI is run under another user than www.

Let me know if this works for you: https://github.com/BrianHenryIE/bh-wc-checkout-rate-limiter/releases/tag/1.1.0

@patrick-leb
Copy link
Author

Sorry for the long delay Brian,
the new version fixed it! :) it's perfect!

Yes, it's working perfectly as a regular plugin. The problem showed itself exclusively when using wpcli, which, indeed, is running a different user.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants