Opened 14 years ago
Closed 11 years ago
#21534 closed defect (bug) (fixed)
Walker: has_children is only set if $args[0] is an array
| Reported by: | betzster | Owned by: | betzster |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.0 |
| Component: | Menus | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch dev-feedback |
| Cc: | Focuses: |
Description
You can't depend on has_children because it doesn't get set if $args[0] is an object. This is obviously an easy fix, just check if it's an object and set it in that case.
Related: #15214
Attachments (3)
Change History (15)
#1
@
13 years ago
Any particular reason this hasn't gotten pushed in, yet? The patch works correctly; I came up with the same solution independently and popped over to report it myself.
#2
follow-up:
↓ 3
@
13 years ago
- Keywords needs-refresh added
As far as I can see, $args is always an array in core. A piece of code to reproduce the issue might be helpful.
The patch needs a refresh after [23346].
#3
in reply to: ↑ 2
;
follow-up:
↓ 4
@
13 years ago
- Keywords needs-refresh removed
Replying to SergeyBiryukov:
As far as I can see,
$argsis always an array in core. A piece of code to reproduce the issue might be helpful.
$args itself is an array, but seems like the first index might not always be.
21534.diff covers the refresh of sorts.
#4
in reply to: ↑ 3
@
13 years ago
- Keywords commit 3.7-early added
- Milestone Awaiting Review → Future Release
- Version 3.4.1 → 3.0
Found an explanation in #15214.
In wp_nav_menu(), $args is an object:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/nav-menu-template.php#L145
Via walk_nav_menu_tree(), it ends up being $args[0] in Walker::display_element().
#6
follow-up:
↓ 7
@
13 years ago
I don't have an objection to this, but just to confirm, does it make more sense to do 21534.diff than inside the nav menu API?
#7
in reply to: ↑ 6
@
13 years ago
Replying to nacin:
I don't have an objection to this, but just to confirm, does it make more sense to do 21534.diff than inside the nav menu API?
I wonder if we should switch the nav menu API to not use objects, or if that will break plugins...
Seems strange that it does use objects instead of arrays.
#8
@
13 years ago
Would 21534.2.diff fix this? It appears we used an object for some kind of convenience or whatever, but clearly walk_nav_menu_tree() should have received it in array form for it to be passed to Walker::walk().
#9
@
13 years ago
- Milestone 3.7 → Future Release
This is not a regression, and seems to me like either 21534.2.diff would make sense as a specific fix, or casting $args[0] from an object to an array in Walker::display_element() would make sense as a general fix.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Check if $args[0] is an object, and also set has_children in that case.