Description
Description:
A fatal error occurs when the plugin is used on a site where the service_data option is a non-array value (string), causing a TypeError on PHP 8+:
PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /wp-content/plugins/optimole-wp/inc/admin.php:1447
Expected:
- Plugin handles corrupted or unexpected
service_data values gracefully and does not crash.
Actual:
- Plugin checks only
!empty($service_data) and then accesses $service_data['domain_dns'], which fatals if $service_data is a string. This can occur if the WordPress option is unexpectedly stored as a string. Affected area: Optml_Admin->localize_dashboard_app.
- Bug triggered in PHP 8+. In older PHP versions this was not fatal but in PHP 8+ it stops all plugin functionality with a hard error.
Step-by-step reproduction instructions
- Trigger a situation where the option
service_data in wp_options is a string (corruption, failed write, or API/caching layer returns a string).
- Visit the Optimole dashboard or any admin page that triggers
Optml_Admin->enqueue() and then Optml_Admin->localize_dashboard_app().
- Observe the fatal error in logs (TypeError: Cannot access offset of type string on string in admin.php line 1447).
Screenshots, screen recording, code snippet or Help Scout ticket
Error message from logs:
PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /wp-content/plugins/optimole-wp/inc/admin.php:1447
Stack trace:
#0 ... Optml_Admin->localize_dashboard_app()
...
Problem lines:
https://github.com/Codeinwp/optimole-wp/blob/master/inc/admin.php#L1447
https://github.com/Codeinwp/optimole-wp/blob/master/inc/admin.php#L1449
Suggested fix: Check with is_array($service_data) before accessing as array.
Reported here: https://secure.helpscout.net/conversation/3293257808/487980
Environment info
No response
Is the issue you are reporting a regression
No
Description
Description:
A fatal error occurs when the plugin is used on a site where the
service_dataoption is a non-array value (string), causing a TypeError on PHP 8+:PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /wp-content/plugins/optimole-wp/inc/admin.php:1447Expected:
service_datavalues gracefully and does not crash.Actual:
!empty($service_data)and then accesses$service_data['domain_dns'], which fatals if$service_datais a string. This can occur if the WordPress option is unexpectedly stored as a string. Affected area:Optml_Admin->localize_dashboard_app.Step-by-step reproduction instructions
service_datainwp_optionsis a string (corruption, failed write, or API/caching layer returns a string).Optml_Admin->enqueue()and thenOptml_Admin->localize_dashboard_app().Screenshots, screen recording, code snippet or Help Scout ticket
Error message from logs:
Problem lines:
https://github.com/Codeinwp/optimole-wp/blob/master/inc/admin.php#L1447
https://github.com/Codeinwp/optimole-wp/blob/master/inc/admin.php#L1449
Suggested fix: Check with
is_array($service_data)before accessing as array.Reported here: https://secure.helpscout.net/conversation/3293257808/487980
Environment info
No response
Is the issue you are reporting a regression
No