Open
Reported for: WPML Multilingual CMS 4.6.6
Overview of the issue
If you’ve been using the Use directory for default language option and its root page feature, and later decided to delete this page, you may encounter an issue in environments running PHP 8. This action can lead to a fatal error as described below:
Fatal error: Uncaught TypeError: get_object_vars(): Argument #1 ($object) must be of type object, null given in .../wp-includes/class-wp-post.php:266 Stack trace: #0 .../wp-includes/class-wp-post.php(266): get_object_vars(NULL) #1 .../wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-root-page-actions.class.php(289): WP_Post->__construct(NULL) #2 .../wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-root-page-actions.class.php(268): WPML_Root_Page_Actions->set_page_query_parameters(Object(WP_Query), 11) #3 .../wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-root-page-actions.class.php(281): WPML_Root_Page_Actions->wpml_home_url_parse_query(Object(WP_Query), 'action_wpml_hom...') #4 .../wp-includes/class-wp-hook.php(310): WPML_Root_Page_Actions->action_wpml_home_url_parse_query(Object(WP_Query)) #5 .../wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(Object(WP_Query), Array) #6 .../wp-includes/plugin.php(565): WP_Hook->do_action(Array) #7 .../wp-includes/class-wp-query.php(1140): do_action_ref_array('parse_query', Array) #8 .../wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-root-page-actions.class.php(263): WP_Query->parse_query(Array) #9 .../wp-includes/class-wp-hook.php(310): WPML_Root_Page_Actions->wpml_home_url_parse_query(Object(WP_Query)) #10 .../wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(Object(WP_Query), Array) #11 .../wp-includes/plugin.php(565): WP_Hook->do_action(Array) #12 .../wp-includes/class-wp-query.php(1140): do_action_ref_array('parse_query', Array) #13 .../wp-includes/class-wp-query.php(1868): WP_Query->parse_query() #14 .../wp-includes/class-wp-query.php(3800): WP_Query->get_posts() #15 .../wp-includes/class-wp.php(662): WP_Query->query(Array) #16 .../wp-includes/class-wp.php(782): WP->query_posts() #17 .../wp-includes/functions.php(1335): WP->main('') #18 .../wp-blog-header.php(16): wp() #19 .../index.php(17): require('/Users/diegoper...') #20 {main} thrown in .../wp-includes/class-wp-post.php on line 266
Workaround
- Go to WPML > Languages > Language URL format page.
- Disable the Use directory for default language option.
- Enable it again.
- Generate a new page if needed.