[wp-trac] [WordPress Trac] #61799: Calling wp_update_nav_menu_item() with an invalid taxonomy causes a fatal error

WordPress Trac noreply at wordpress.org
Thu Aug 1 05:36:09 UTC 2024


#61799: Calling wp_update_nav_menu_item() with an invalid taxonomy causes a fatal
error
--------------------------+-----------------------------
 Reporter:  dd32          |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Import        |    Version:  5.5
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 For background, please see https://github.com/WordPress/wordpress-
 importer/issues/164

 When attempting to import a WXR which contains a Nav menu item that
 references a taxonomy that doesn't exist on the site,
 wp_update_nav_menu_item() will hit a fatal error.

 {{{
 PHP Fatal error:  Uncaught Error: Object of class WP_Error could not be
 converted to string in /wordpress/wp-includes/formatting.php:2
 Stack trace:
 #0 /wordpress/wp-includes/nav-menu.php(2):
 wp_specialchars_decode(Object(WP_Error))
 #1 /wordpress/wp-content/plugins/wordpress-importer/class-wp-
 import.php(996): wp_update_nav_menu_item(3, 0, Array)
 #2 /wordpress/wp-content/plugins/wordpress-importer/class-wp-
 import.php(653): WP_Import->process_menu_item(Array)
 #3 /wordpress/wp-content/plugins/wordpress-importer/class-wp-
 import.php(89): WP_Import->process_posts()
 #4 /wordpress/wp-content/plugins/wordpress-importer/class-wp-
 import.php(65): WP_Import->import('/wordpress/wp-c...')
 #5 /wordpress/wp-admin/admin.php(2): WP_Import->dispatch()
 #6 {main}
   thrown in /wordpress/wp-includes/formatting.php on line 2
 }}}

 It appears that invalid post type archives are handled, just not missing
 taxonomies.

 Relevant lines:
 https://core.trac.wordpress.org/browser/tags/6.6/src/wp-includes/nav-
 menu.php?marks=496,509#L484
 `$original_title` will be a `WP_Error` for a non-existent taxonomy in
 `$args['menu-item-object']`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61799>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list