Bug: Fatal error on PHP 8.x due to string offset access
-
Hello,
first of all, thank you for this wonderful plugin — it is greatly appreciated.When using PHP 8.x (tested with PHP 8.2 / 8.4), the plugin throws a fatal error that does not occur with PHP 7.4.
Error message:
Cannot access offset of type string on string /includes/ect-styles.php on line 174Cause:
Inect-styles.php(line 174), an array offset ([...]) is accessed on a variable that is, under certain conditions, a string.
While PHP 7.4 only raised a warning/notice, PHP 8.x treats this as a fatal error (breaking change).Likely affected area:
Unvalidated access to shortcode attributes or option values (missingis_array()/isset()checks).Suggested fix:
Please ensure the variable is an array before accessing offsets, e.g.:if (is_array($var) && isset($var['key'])) { ... }The issue occurs during shortcode rendering and also when saving posts (e.g. triggered via Yoast SEO hooks).
Thank you for providing a PHP 8 compatible fix.
Best regards
You must be logged in to reply to this topic.