Warning: Parameter must implement Countable
dmhendricks opened this issue · 0 comments
dmhendricks commented
- Web: Nginx 1.10.1
- PHP version: 7.2.0
- Database: MySQL 5.6.34
- WordPress: 4.9.6
- W3 Total Cache (Fixed): 0.9.6.1
Error Log:
[02-Jun-2018 18:09:58 UTC] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /app/public/wp-content/plugins/w3-total-cache-fixed/Cdn_Plugin.php on line 1222
[02-Jun-2018 18:09:58 UTC] PHP Stack trace:
[02-Jun-2018 18:09:58 UTC] PHP 1. shutdown_action_hook() /app/public/wp-includes/load.php:0
[02-Jun-2018 18:09:58 UTC] PHP 2. do_action() /app/public/wp-includes/load.php:679
[02-Jun-2018 18:09:58 UTC] PHP 3. WP_Hook->do_action() /app/public/wp-includes/plugin.php:453
[02-Jun-2018 18:09:58 UTC] PHP 4. WP_Hook->apply_filters() /app/public/wp-includes/class-wp-hook.php:310
[02-Jun-2018 18:09:58 UTC] PHP 5. MyPlugin\Namespace\OutputBuffering->MyPlugin\Namespace\OutputBuffering\{closure}() /app/public/wp-includes/class-wp-hook.php:286
[02-Jun-2018 18:09:58 UTC] PHP 6. ob_get_clean() /app/public/wp-content/mu-plugins/output_buffering.php:42
[02-Jun-2018 18:09:58 UTC] PHP 7. W3TC\Generic_Plugin->ob_callback() /app/public/wp-content/mu-plugins/output_buffering.php:42
[02-Jun-2018 18:09:58 UTC] PHP 8. W3TC\Util_Bus::do_ob_callbacks() /app/public/wp-content/plugins/w3-total-cache-fixed/Generic_Plugin.php:527
[02-Jun-2018 18:09:58 UTC] PHP 9. call_user_func:{/app/public/wp-content/plugins/w3-total-cache-fixed/Util_Bus.php:21}() /app/public/wp-content/plugins/w3-total-cache-fixed/Util_Bus.php:21
[02-Jun-2018 18:09:58 UTC] PHP 10. W3TC\Cdn_Plugin->ob_callback() /app/public/wp-content/plugins/w3-total-cache-fixed/Util_Bus.php:21
[02-Jun-2018 18:09:58 UTC] PHP 11. W3TC\_Cdn_Plugin_ContentFilter->get_replaced_urls() /app/public/wp-content/plugins/w3-total-cache-fixed/Cdn_Plugin.php:300
[02-Jun-2018 18:09:58 UTC] PHP 12. count() /app/public/wp-content/plugins/w3-total-cache-fixed/Cdn_Plugin.php:1222
Notes
I'm assuming that W3 Edge will not fix this since they want to support ancient versions of PHP, and it is just a warning. I can fix it myself, but it would be nice if I didn't have to with each update. I can do a PR, but I was hoping someone would make a quick tweak. I can also disable PHP warnings, but I don't want to.
Solution
Change line 1222 in Cdn_Plugin.php
from:
if ( count( $this->_replaced_urls ) ) {
...to:
if ( is_array( $this->_replaced_urls ) && count( $this->_replaced_urls ) ) {
Thank you.