WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#13037 closed defect (bug) (fixed)

Nav menu doesn't like when item is a child of itself

Reported by: johnjamesjacoby Owned by: ryan
Milestone: 3.0 Priority: high
Severity: normal Version: 3.0
Component: Menus Keywords:
Focuses: Cc:

Description (last modified by dd32)

Page - About
----Category - Uncategorized
--------Page - About

Save Menu

Fatal error: Maximum function nesting level of '100' reached, aborting! in (...) on line 147

Attachments (4)

2010-04-17_0539.png (19.7 KB) - added by johnjamesjacoby 4 years ago.
Curse you wiki formatting!
2010-04-17_0540.png (39.5 KB) - added by johnjamesjacoby 4 years ago.
Which leads to…
13037.diff (2.0 KB) - added by duck_ 4 years ago.
13037.2.diff (2.3 KB) - added by duck_ 4 years ago.
update accounts for items with same id but different types

Download all attachments as: .zip

Change History (11)

comment:1 johnjamesjacoby4 years ago

Damn wiki formatting

Page - About
...Category - Uncategorized
......Page - About

johnjamesjacoby4 years ago

Curse you wiki formatting!

johnjamesjacoby4 years ago

Which leads to...

comment:2 dd324 years ago

for reference: to post code & formatted text, wrap it in 3 brackets like this: (Thats wrapped in brackets to show it)

 {{{
  ...the code here...
 }}}

comment:3 dd324 years ago

  • Description modified (diff)
  • Milestone changed from Unassigned to 3.0

comment:4 duck_4 years ago

  • Keywords has-patch needs-testing added

Patch extends current JavaScript for blocking this from happening (does not solve the underlying problem which would exist for non-js version of menus). Might not be the most optimised method for doing this, if this is the case it still serves as an example (especially since the nav menu feature is currently changing).

duck_4 years ago

duck_4 years ago

update accounts for items with same id but different types

comment:5 duck_4 years ago

  • Keywords needs-patch added; has-patch needs-testing removed

This bug has changed since filosofo's major update was applied:

Now if you try to make a post/page/whatever a child of itself in a menu you encounter a JavaScript error any time you try to load the menus page, causing only half of the page to render. Steps:

  • Create a menu
  • Add the same post to menu twice
  • Make post child of itself
  • Click save

The error which occurs:
Uncaught TypeError: Object #<an Object> has no method 'autocomplete', line 312 of nav-menu.dev.js

Using console.log(el) before this call I get the quick-search-posttype-post input element, this suggests this is the element throwing the error.

Not had much chance to look into this, busy with exams :-(, but seems like there a no checks in place to stop menu elements being children of themselves.

comment:6 duck_4 years ago

The same problem is also encountered when trying to set an item as the child of another item but has the same ID (i.e. the same menu-item-object-id). An example of this is with Hello World post (id = 1) and Uncategorized (id = 1).

Side note: issues also crop up with clashing IDs when you try to make a third item (say the About page) a child of the clashing item further down the menu:

Start with:

- About
- Hello World
- Uncategorized

Move About to child of Uncategorized:

- Hello World
- Uncategorized
---- About

Save, and you end up with:

- Hello World
---- About
- Uncategorized

comment:7 duck_4 years ago

  • Keywords needs-patch removed
  • Resolution set to fixed
  • Status changed from new to closed

See [14450] and #13249

Note: See TracTickets for help on using tickets.