Opened 10 months ago

Last modified 5 weeks ago

#21534 new defect (bug)

Walker: has_children is only set if $args[0] is an array

Reported by: betzster Owned by: betzster
Priority: normal Milestone: Future Release
Component: Menus Version: 3.0
Severity: normal Keywords: has-patch commit 3.7-early
Cc:

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 (2)

has_children.patch (623 bytes) - added by betzster 10 months ago.
Check if $args[0] is an object, and also set has_children in that case.
21534.diff (839 bytes) - added by DrewAPicture 5 weeks ago.

Download all attachments as: .zip

Change History (6)

Check if $args[0] is an object, and also set has_children in that case.

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.

comment:2 follow-up: ↓ 3   SergeyBiryukov5 weeks 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].

comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4   DrewAPicture5 weeks ago

  • Keywords needs-refresh removed

Replying to SergeyBiryukov:

As far as I can see, $args is 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.

comment:4 in reply to: ↑ 3   SergeyBiryukov5 weeks ago

  • Keywords commit 3.7-early added
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 3.4.1 to 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().

Note: See TracTickets for help on using tickets.