This thread is resolved. Here is a description of the problem and solution.
Problem:
We switched from PHP 7.4 to PHP 8.0, and the url_to_postid() call crashes the website.
I got:
Fatal error: Uncaught Error: Illegal offset type in isset or empty in /home/.../wp-content/plugins/sitepress-multilingual-cms/classes/url-handling/converter/class-wpml-url-cached-converter.php on line 46 Call stack: WPML_URL_Cached_Converter::get_language_from_url() wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php:4423 SitePress::get_language_from_url() wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php:4394 SitePress::maybe_adjust_url() wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php:4276 SitePress::url_to_postid() wp-includes/class-wp-hook.php:308 WP_Hook::apply_filters() wp-includes/plugin.php:205 apply_filters() wp-includes/rewrite.php:501 url_to_postid() wp-content/themes/dz-theme/inc/location.php:246
Solution:
This was not a WPML issue. Something in the code of the user caused this issue. The user wrote:
We found the root cause: the URL parameter was in some occasion a SimpleXMLElement instance and not a string. We added a type cast to a string and it works now fine.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 15 replies, has 2 voices.
Last updated by Itamar 1 year, 3 months ago.
Assisted by: Itamar.