Opened 11 years ago
Closed 11 years ago
#26795 closed defect (bug) (fixed)
Navigation Menu does not updates after a page or post is deleted, which leads to inconsistent menu in backend and frontend
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | major | Version: | 3.7 |
Component: | Menus | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
If I've added a page in menu and later I delete it permanently, It does not get remove from menu items and instead displays notice as $original_object = get_post( $menu_item->object_id );
in nav_menu.php
on line 596 returns nothing.
Theme: Twentyfourteen
Wordpress Version 3.8
To replicate the issue:
- Create a Normal Page.
- Add page to menu and Update it.
- Delete the Page Permanently
- If debug is turned, php notice are there on the menu page in backend as well as frontend. If debug is off you can still see the space for items in menu.
- On saving the menu back, the menu item is removed.
It happens as _wp_delete_post_menu_item
is not updating the menu items on delete_post
hook
Attachments (7)
Change History (29)
#2
@
11 years ago
Dropping a comment on this ticket as the new ticket notification accidentally did not go out.
#7
@
11 years ago
I just looked at your patch to leave my first comment. I have experienced this issue before but never looked into it.
The removed code I don't know yet if that is needed but I do believe that this doesn't solve the whole problem. The problem to me is that the menu item isn't removed and I would expect that would be the case. To me that should be addressed too.
I'm curious if we should show an indication that a page/post is in a menu. Also I do want to mention that 3 days is a short period. Sometimes it takes a bit longer that someone has the time to look into it.
#8
@
11 years ago
@markoheijnen The above patch only fixes the issue when you are permanently deleting a page and not if you just trash it.
It works absolutely fine for me, does it not fixes the issue for you if you permanently delete (and not trash) a page or post?
#9
@
11 years ago
- Keywords needs-patch added; has-patch needs-testing removed
- Milestone changed from Awaiting Review to 3.9
The issue is, that _wp_delete_post_menu_item()
doesn't delete the nav menu object. _wp_delete_post_menu_item()
is hooked into delete_post
.
#10
@
11 years ago
- Keywords has-patch needs-unit-tests added; needs-patch removed
Haven't seen 26795.nav-menu.php.patch which works for me after a quick test.
The unit test test_wp_get_associated_nav_menu_items()
should be extend for post types.
#11
@
11 years ago
- Keywords needs-patch added; has-patch needs-unit-tests removed
It'll require both the changes filter wp_trash_post
and changes in wp_get_associated_nav_menu_items
#15
@
11 years ago
I just checked the ticket, there is a long debate to not remove items from menu if post/page is trashed.
So we could just go with the patch 26795.nav-menu.php.patch if it goes good with with the testing.
#16
follow-up:
↓ 21
@
11 years ago
- Keywords needs-unit-tests removed
26795.patch should fix this. _menu_item_object
is not relevant for post types.
#18
@
11 years ago
- Summary changed from Deleting a page do not updates menu items and generates Notices in frontend and backend to Navigation Menu does not updates after a page or post is deleted, which leads to inconsistent menu in backend and frontend
Space for deleted pages in backend still appears.