WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 3 weeks ago

#24548 new defect (bug)

_wp_menu_item_classes_by_context assumes $queried_object->ancestors is an array

Reported by: wpsmith Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Menus Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

Recently, on a site using CPT-onomies, I ran into an interesting error with _wp_menu_item_classes_by_context().

In this function, when setting the parent class, there is a large if statement that assumes that $queried_object->ancestors and $possible_taxonomy_ancestors[ $parent_item->object ] are arrays.

Attachments (1)

nav-menu-template.php.24548.patch (948 bytes) - added by wpsmith 10 months ago.

Download all attachments as: .zip

Change History (3)

comment:1 wonderboymusic8 weeks ago

  • Milestone changed from Awaiting Review to 3.9

This function...

comment:2 nacin3 weeks ago

  • Keywords reporter-feedback added; dev-feedback removed
  • Milestone changed from 3.9 to Awaiting Review

When are either of these not arrays?

For the first one, post objects always return get_post_ancestors(), which always returns an array. (It briefly did not: #22882.)

For the second one, that array must be set (the line above it) before it is treated as an array. It is set to be an array within the function.

Note: See TracTickets for help on using tickets.