Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
russellgilbert opened this issue Feb 19, 2023 · 0 comments

Comments

@russellgilbert
Copy link

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.

@russellgilbert russellgilbert changed the title get_option() returns false in get_settings() get_option() returns false in get_settings() in version 1.6.0 Feb 19, 2023
@russellgilbert russellgilbert changed the title get_option() returns false in get_settings() in version 1.6.0 Fatal error: get_option() returns false in get_settings() in version 1.6.0 Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant