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

Fatal error thrown at checkout #16

Closed
dixonl90 opened this issue Nov 23, 2022 · 2 comments
Closed

Fatal error thrown at checkout #16

dixonl90 opened this issue Nov 23, 2022 · 2 comments

Comments

@dixonl90
Copy link

Hello!

This looks like a great plugin, thanks for putting in the time to make it.

I've installed on my development environment, however once I click checkout on the checkout page the following fatal error is thrown:

PHP Fatal error:  Declaration of BrianHenryIE\Checkout_Rate_Limiter\WpOop\TransientCache\CachePool::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed in /srv/www/devsite/current/web/app/plugins/bh-wc-checkout-rate-limiter/vendor-prefixed/wp-oop/transient-cache/src/CachePool.php on line 93

Here's the logs

2022-11-23T10:05:23+00:00 DEBUG Checking 192.168.57.1 rate limit 2 per 60 seconds.
{"debug_backtrace":[{"file":"\/srv\/www\/devsite\/current\/web\/app\/plugins\/bh-wc-checkout-rate-limiter\/src\/WooCommerce\/class-ajax.php","lineNumber":78,"arguments":[],"applicationFrame":false,"method":"[top]","class":null}],"filters":["template_redirect","wc_ajax_checkout"]}
2022-11-23T10:05:23+00:00 ERROR Declaration of BrianHenryIE\Checkout_Rate_Limiter\WpOop\TransientCache\CachePool::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed
{"type":64,"message":"Declaration of BrianHenryIE\\Checkout_Rate_Limiter\\WpOop\\TransientCache\\CachePool::get($key, $default = null) must be compatible with Psr\\SimpleCache\\CacheInterface::get(string $key, mixed $default = null): mixed","file":"\/srv\/www\/devsite\/current\/web\/app\/plugins\/bh-wc-checkout-rate-limiter\/vendor-prefixed\/wp-oop\/transient-cache\/src\/CachePool.php","line":93,"debug_backtrace":[{"file":"\/srv\/www\/devsite\/current\/web\/app\/plugins\/bh-wc-checkout-rate-limiter\/vendor-prefixed\/brianhenryie\/bh-wp-logger\/src\/PHP\/class-php-shutdown-handler.php","lineNumber":87,"arguments":[],"applicationFrame":true,"method":"handle","class":"BrianHenryIE\\Checkout_Rate_Limiter\\WP_Logger\\PHP\\PHP_Shutdown_Handler"},{"file":"unknown","lineNumber":0,"arguments":[],"applicationFrame":false,"method":"[top]","class":null}],"filters":["template_redirect","wc_ajax_checkout"]}

Looks like it's due to the difference in some implementations, here's Psr\SimpleCache\CacheInterface:

public function get(string $key, mixed $default = null): mixed;

This is BrianHenryIE\Checkout_Rate_Limiter\WpOop\TransientCache\CachePool

public function get($key, $default = null)

In theory it should be a simple change of definitions.

Env details:
WC Version: 5.8.1
WP Version: 5.9.3
PHP Version: 8.0.17

@dixonl90 dixonl90 changed the title Fatal error thown at checkoout Fatal error thrown at checkout Nov 23, 2022
@dixonl90
Copy link
Author

On further investigation it appears the issue is that another plugin includes a newer version of Psr\SimpleCache which has the types specified.

@BrianHenryIE
Copy link
Owner

I've another project BrianHenryIE/strauss which prefixes Composer packages' namespaces. I had intentionally excluded psr/* packages from prefixing since their purpose is interoperability. Maybe that's the wrong choice. I've made sure to prefix simple-cache in this project now. 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