{"id":7304,"date":"2023-09-16T08:41:36","date_gmt":"2023-09-16T08:41:36","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=7304"},"modified":"2023-09-16T08:41:39","modified_gmt":"2023-09-16T08:41:39","slug":"issue-upgrading-wordpress-site-to-php-8-due-to-plugin-cannot-access-offset-of-type-string-on-string","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/issue-upgrading-wordpress-site-to-php-8-due-to-plugin-cannot-access-offset-of-type-string-on-string","title":{"rendered":"Issue upgrading WordPress Site to PHP 8 due to Plugin &#8211; Cannot access offset of type string on string"},"content":{"rendered":"\n<p>I tried to upgrade a WordPress Site however I got the dreaded<\/p>\n\n\n\n<p><strong>There Has Been a Critical Error on Your Website<\/strong><\/p>\n\n\n\n<p>I turned full Debug mode on the website wp_config.php to show me the error<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">define('WP_DEBUG', true);\ndefine( 'WP_DEBUG_LOG', true);\ndefine( 'WP_DEBUG_DISPLAY', true);<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Uncaught TypeError: Cannot access offset of type string on string<\/p>\n\n\n\n<p>Looking at the code the plugin&#8217;s vendor declared a String for an Array variable<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">                $post_services_name = \"\";\n\n                foreach ( $pt_posts_services as $post ) : setup_postdata( $post );\n                    $post_services_name[$post->post_title]=$post->post_name;\n\n                endforeach;<\/code><\/pre>\n\n\n\n<p>Defining the array before fixed it<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">                    $post_services_name = array();\n\n                    foreach ( $pt_posts_services as $post ) : setup_postdata( $post );\n                        $post_services_name[$post->post_title]=$post->post_name;\n\n                    endforeach;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I tried to upgrade a WordPress Site however I got the dreaded There Has Been a Critical Error on Your Website I turned full Debug mode on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7304","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/7304","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=7304"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/7304\/revisions"}],"predecessor-version":[{"id":7305,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/7304\/revisions\/7305"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=7304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=7304"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=7304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}