WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 weeks ago

#34657 closed defect (bug) (wontfix)

WordPress doesn't set object terms for menu items so pending items not working

Reported by: rss_samuel Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3.1
Component: Menus Keywords: dev-feedback has-patch reporter-feedback
Focuses: administration Cc:

Description (last modified by SergeyBiryukov)

When I create menu items and refresh admin page without saving menu, wordpress can not show pending menu items.

At line 1127 of 'wp-admin/includes/ajax-functions.php' file there is wp_save_nav_menu_items function, the first argument for this function is always zero, so At line 441 of 'wp-includes/nav-menu.php' file wp_set_object_terms function doesn't work.

I add my menu id to

$item_ids = wp_save_nav_menu_items( 97, $menu_items_data );

function, and it working for me. :)

Attachments (1)

34657.patch​ (1.2 KB) - added by rss_samuel 2 years ago.
I change /wp-admin/includes/ajax-actions.php file.

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
3 years ago

  • Description modified (diff)
  • Summary changed from Wordpress doesn't set object terms for menu items so pending items not working to WordPress doesn't set object terms for menu items so pending items not working

#2 @welcher
2 years ago

Hi!

Thanks for the ticket! It looks like you have an idea of how to address this - did you want to submit a patch?

#3 @welcher
2 years ago

  • Keywords needs-patch added

@rss_samuel
2 years ago

I change /wp-admin/includes/ajax-actions.php file.

#4 @rss_samuel
2 years ago

After changes it works for me. https://i.imgsafe.org/3ee6fa389a.png

#5 @welcher
2 years ago

  • Keywords dev-feedback has-patch reporter-feedback added; needs-patch removed

Thanks for the patch!

Just one thing - I'm not sure we should be dying if $_POST['menu'] is not set. That block is meant to check whether the user has the capability to do this and it shouldn't ( in my opinion ) care if that item is set.

If we're just wanting to be sure that there is a value passed to the wp_save_nav_menu_items it might be a good idea to use a ternary instead.

i.e $menu_id = ( isset( $_POST['menu'] ) ) ? absint( $_POST['menu'] ) : 0;

Last edited 2 years ago by welcher (previous) (diff)

#6 @iseulde
3 weeks ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

This ticket has not seen any activity in over *two* years, so I'm closing it as "wontfix".

The ticket may lack decisiveness, may have become irrelevant, or may not have gathered enough interest.

If you think this ticket does deserve some attention again, feel free to reopen.

For bugs, it would be great if you could provide updated steps to reproduce against the latest version of WordPress (5.0.2 at the time of writing). Remember images or a video can be superior to explain a problem. At the very least, quickly test again to make sure the bug still exists.

If it’s an enhancement or feature, some extra motivation may help.

Thank you for your contributions to WordPress! <3

Note: See TracTickets for help on using tickets.