[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:39:17 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        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by dd32):

 Untested, but it might be enough to simply avoid the fatal on update and
 leave the menu code to resolve the issue elsewhere:

 {{{#!diff
 Index: nav-menu.php
 ===================================================================
 --- nav-menu.php        (revision 58230)
 +++ nav-menu.php        (working copy)
 @@ -491,7 +491,7 @@
                 $args['menu-item-url'] = '';

                 $original_title = '';
 -               if ( 'taxonomy' === $args['menu-item-type'] ) {
 +               if ( 'taxonomy' === $args['menu-item-type'] &&
 taxonomy_exists( $args['menu-item-object'] ) ) {
                         $original_parent = get_term_field( 'parent', $args
 ['menu-item-object-id'], $args['menu-item-object'], 'raw' );
                         $original_title  = get_term_field( 'name', $args
 ['menu-item-object-id'], $args['menu-item-object'], 'raw' );
                 } elseif ( 'post_type' === $args['menu-item-type'] ) {
 }}}

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


More information about the wp-trac mailing list