Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#34803 new defect (bug)

Deleting menu item with sub-items does not update sub-items' parent (with disabled JS)

Reported by: janvoracek's profile JanVoracek Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

This bug appears only with disabled JavaScript.

If I create menu with following structure:

  • Parent
    • Child 1
      • Child 2

and I delete Child 1, it should look like this:

  • Parent
    • Child 2

The problem is that WP does not update the Child 2 's parent (postmeta _menu_item_menu_item_parent) with disabled JavaScript.

Attachments (2)

34803.diff (1.1 KB) - added by shooper 9 years ago.
Reassign child nav menu items to the grandparent before deleting a nav-menu-item post.
34803-2.diff (3.7 KB) - added by shooper 9 years ago.
Updated patch that clears child cache & includes test coverage

Download all attachments as: .zip

Change History (8)

#1 @borekb
9 years ago

  • Keywords needs-patch added
  • Severity changed from trivial to normal

@shooper
9 years ago

Reassign child nav menu items to the grandparent before deleting a nav-menu-item post.

#2 @shooper
9 years ago

  • Keywords has-patch added; needs-patch removed

#3 @borekb
9 years ago

  • Keywords dev-feedback added

Tried the patch 34803.diff and can confirm that it works for a couple of scenarios that I tested.

#4 @danielbachhuber
9 years ago

  • Keywords needs-unit-tests added; dev-feedback removed

Few points of feedback on the patch:

  • I like how the logic is internalised to wp_delete_post(). Seems reasonable.
  • Like parent post reassignment immediately preceding in the function call, the procedure should also clear meta cache for affected nav items.
  • Needs test coverage.

#5 @shooper
9 years ago

Also discovered my setting of the $children variable in my nav menu item loop would have broken the cache clearing done for child posts. Updating patch based on @danielbachhuber's comments.

@shooper
9 years ago

Updated patch that clears child cache & includes test coverage

#6 @shooper
9 years ago

  • Keywords needs-unit-tests removed
Note: See TracTickets for help on using tickets.