Fatal error with php 8.3.26
-
Hello,
I encountered the following error message in the server logs :PHP Warning: Undefined array key “weekdays” in /wp-content/plugins/google-captcha/includes/class-gglcptch-settings-tabs.php on line 348
PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /wp-content/plugins/google-captcha/includes/class-gglcptch-settings-tabs.php:348
Stack trace: 0 /wp-content/plugins/google-captcha/includes/class-gglcptch-settings-tabs.php(348): in_array() 1 /wp-content/plugins/google-captcha/bws_menu/class-bws-settings.php(351): Gglcptch_Settings_Tabs->tab_settings() 2 /wp-content/plugins/google-captcha/bws_menu/class-bws-settings.php(297): Bws_Settings_Tabs->display_tabs_content()This happens when the $options[‘weekdays’] or $options[‘all_day’] keys are not initialized in the plugin options array, causing in_array() to receive null instead of an array.
As a temporary fix, I added the following lines to initialize these variables before they are used :
$weekdays = isset( $this->options[‘weekdays’] ) && is_array( $this->options[‘weekdays’] ) ? $this->options[‘weekdays’] : [];
$all_day = isset( $this->options[‘all_day’] ) && is_array( $this->options[‘all_day’] ) ? $this->options[‘all_day’] : [];After adding this initialization, the error no longer occurs.
It might be helpful to include a similar check in a future update to prevent fatal errors when the plugin options are not fully initialized.
Thank you.
You must be logged in to reply to this topic.