The Events Calendar PRO – PHP 8.2 Fatal Error
-
I understand that PHP 8.2 support for The Events Calendar plugin, and assuming The Events Calendar PRO plugin, is still in progress, so this is more of an attempt to get a bug ticket out in the open.
The site I’m working on is on WPEngine, which is forcing sites on PHP 8.0 to be updated to 8.2 by late October. Below is the fatal error that occurs when the site was upgraded to 8.2:
[29-Sep-2023 17:07:26 UTC] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /nas/content/live/mytestsite/wp-content/plugins/events-calendar-pro/src/Tribe/Customizer/Section.php:213 Stack trace: #0 /nas/content/live/mytestsite/wp-includes/class-wp-hook.php(308): Tribe__Events__Pro__Customizer__Section->filter_settings(Array, NULL) #1 /nas/content/live/mytestsite/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #2 /nas/content/live/mytestsite/wp-content/plugins/events-calendar-pro/src/Tribe/Customizer/Main.php(174): apply_filters('tribe_events_pr...', Array, NULL) #3 /nas/content/live/mytestsite/wp-content/plugins/events-calendar-pro/src/Tribe/Customizer/Main.php(203): Tribe__Events__Pro__Customizer__Main->get_option() #4 /nas/content/live/mytestsite/wp-content/plugins/events-calendar-pro/src/Tribe/Customizer/Section_Day_List_View.php(35): Tribe__Events__Pro__Customizer__Main->has_option('day_list_view', 'price_bg_color') #5 /nas/content/live/mytestsite/wp-includes/class-wp-hook.php(308): Tribe__Events__Pro__Customizer__Section_Day_List_View->get_css_template('') #6 /nas/content/live/mytestsite/wp-includes/plugin.php(205): WP_Hook->apply_filters('', Array) #7 /nas/content/live/mytestsite/wp-content/plugins/events-calendar-pro/src/Tribe/Customizer/Main.php(235): apply_filters('tribe_events_pr...', '') #8 /nas/content/live/mytestsite/wp-includes/class-wp-hook.php(308): Tribe__Events__Pro__Customizer__Main->print_css_template('') #9 /nas/content/live/mytestsite/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #10 /nas/content/live/mytestsite/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #11 /nas/content/live/mytestsite/wp-includes/script-loader.php(2177): do_action('wp_print_footer...') #12 /nas/content/live/mytestsite/wp-includes/class-wp-hook.php(308): wp_print_footer_scripts('') #13 /nas/content/live/mytestsite/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array) #14 /nas/content/live/mytestsite/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #15 /nas/content/live/mytestsite/wp-includes/general-template.php(3065): do_action('wp_footer') #16 /nas/content/live/mytestsite/wp-content/themes/nic/footer.php(63): wp_footer() #17 /nas/content/live/mytestsite/wp-includes/template.php(783): require_once('/nas/content/li...') #18 /nas/content/live/mytestsite/wp-includes/template.php(718): load_template('/nas/content/li...', true, Array) #19 /nas/content/live/mytestsite/wp-includes/general-template.php(92): locate_template(Array, true, true, Array) #20 /nas/content/live/mytestsite/wp-content/themes/nic/front-page.php(93): get_footer() #21 /nas/content/live/mytestsite/wp-includes/template-loader.php(106): include('/nas/content/li...') #22 /nas/content/live/mytestsite/wp-blog-header.php(19): require_once('/nas/content/li...') #23 /nas/content/live/mytestsite/index.php(17): require('/nas/content/li...') #24 {main} thrown in /nas/content/live/mytestsite/wp-content/plugins/events-calendar-pro/src/Tribe/Customizer/Section.php on line 213
The fatal error occurs even when all unnecessary plugins are deactivated, and the theme is changed to a stock WP theme.
This is the code block that is causing the fatal error:
if ( count( $search ) === 1 ) { //this is line 213 $settings = $this->create_ghost_settings( $settings ); } else { $settings[ $this->ID ] = $this->create_ghost_settings( $settings[ $this->ID ] ); }
I added a
is_null()
check in thefilter_settings
function, and this – naturally – prevented the null value from causing the fatal error. I believe something like this will need to be put in place somewhere in thefilter_settings
function, to prevent the assumption that$search
contains data.The page I need help with: [log in to see the link]
- The topic ‘The Events Calendar PRO – PHP 8.2 Fatal Error’ is closed to new replies.