deliciousbrains / wp-offload-ses-lite

WP Offload SES Lite sends all outgoing WordPress emails through Amazon Simple Email Service (SES) instead of the local wp_mail() function.
https://wordpress.org/plugins/wp-ses/
13 stars 11 forks source link

Fatal error: get_option() returns false in get_settings() in version 1.6.0 #45

Open russellgilbert opened 1 year ago

russellgilbert commented 1 year ago

After upgrading to version 1.6.0, my site is crashing while displaying any page. Looking at the PHP error log, I see:

PHP Fatal error: Uncaught TypeError: Argument 1 passed to DeliciousBrains\WP_Offload_SES\Settings::filter_settings() must be of the type array, bool given, called in /www/MYSITE.com/html/wp-content/plugins/wp-ses/classes/Settings.php on line 83 and defined in /www/MYSITE.com/html/wp-content/plugins/wp-ses/classes/Settings.php:279

The problem seems to be with this code on line 83 of wp-ses/classes/Settings.php:

$this->settings = $this->filter_settings( get_option( $this->settings_key, array() ) );

I believe get_option() is returning false, which is then passed unchecked to filter_settings(), which causes the fatal error.

As a workaround, I modified the line to check for a valid return from get_option(), and force it to be an empty array if it's not:

$this->settings = $this->filter_settings( get_option( $this->settings_key, array() ) ?: array() );

And the same on line 79:

$subsite_settings = get_option( $this->settings_key, array() ) ?: array();

My site then worked again, although I haven't tested the plugin.