PHP Fatal Error with PHP8
-
Hello. I see this error in the logs when using this plugin. I’ve manged to fix it by directly editing the plugin files but it would be good if you could take a look as well.
PHP Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, null given in /wp-content/plugins/cookie-control/cookiecontrol.php:1164\nStack trace:\n#0 /wp-includes/class-wp-hook.php(308): cookiecontrol_args()\n#1 /wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()\n#2 /wp-includes/plugin.php(517): WP_Hook->do_action()\n#3 /wp-includes/general-template.php(3059): do_action()\n#4 /wp-content/themes/theme/footer-home.php(138): wp_footer()\n#5 /wp-includes/template.php(783): require_once('...')\n#6 /wp-includes/template.php(718): load_template()\n#7 /wp-includes/general-template.php(92): locate_template()\n#8 /wp-content/themes/theme/home.php(294): get_footer()\n#9 /wp-includes/template-loader.php(106): include('...')\n#10 /wp-blog-header.php(19): require_once('...')\n#11 /index.php(17): require('...')\n#12 {main}\n thrown in /wp-content/plugins/cookie-control/cookiecontrol.php on line 1164,
All the sizeof calls in the cookiecontrol.php are throwing an error, a simple fix would be to check if $cookiecontrol_settings[‘altLanguages’] is an array before checking sizeof
<?php if ( is_array($cookiecontrol_settings[‘excludedCountries’]) && sizeof($cookiecontrol_settings[‘excludedCountries’]) > 0 && !empty($cookiecontrol_settings[‘excludedCountries’]) ) : ?>
Thanks
Michal
- The topic ‘PHP Fatal Error with PHP8’ is closed to new replies.