How to Resolve a Fatal Error Caused by Smush Pro

At A Glance:
– Updating the plugin may resolve the error.
– The error can be resolved by downgrading the PHP version to 7.4 > updating the API status > changing the PHP version back to 8.0

Fatal Error

You may see a similar error log when encountering a Smush fatal error and have debugging enabled.

[31-May-2023 00:27:47 UTC] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /var/www/wp-content/plugins/wp-smush-pro/core/api/class-smush-api.php:90
Stack trace:
#0 /var/www/wp-content/plugins/wp-smush-pro/core/api/class-smush-api.php(50): Smush\Core\Api\Smush_API->backoff_sync(Object(Closure), false)
#1 /var/www/wp-content/plugins/wp-smush-pro/wp-smush.php(514): Smush\Core\Api\Smush_API->check(false)
#2 /var/www/wp-content/plugins/wp-smush-pro/wp-smush.php(290): WP_Smush->validate_install()
#3 /var/www/wp-content/plugins/wp-smush-pro/wp-smush.php(232): WP_Smush->init()
#4 /var/www/wp-content/plugins/wp-smush-pro/wp-smush.php(208): WP_Smush->__construct()
#5 /var/www/wp-includes/class-wp-hook.php(308): WP_Smush::get_instance('')
#6 /var/www/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#7 /var/www/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#8 /var/www/wp-settings.php(486): do_action('plugins_loaded')
#9 /var/www/wp-config.php(104): require_once('/var/www/wp-set...')
#10 /var/www/wp-content/mu-plugins/gd-system-plugin/plugins/mwp-cron/run-cron.php(37): require_once('/var/www/wp-con...')
#11 {main}
  thrown in /var/www/wp-content/plugins/wp-smush-pro/core/api/class-smush-api.php on line 90

The error can be resolved by downgrading the PHP version to 7.4 > updating the API status > changing the PHP version back to 8.0

Resolving The Error

  1. Updating the plugin may resolve the error. This bug may have been patched according to a recent changelog.
  2. Downgrade the PHP version to 7.4 by Changing PHP Version in the hosting settings.
  3. Update the API status in the Smush settings from the WP Admin Dashboard > Smush Pro > Settings > Data & Settings > UPDATE API STATUS button.
  1. Change the PHP version back to 8.0 in the hosting settings.