Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#39849 closed defect (bug) (fixed)

Filter `nav_menu_items_{$post_type_name}_recent` passes base args, not recent

Reported by: eclev91's profile eclev91 Owned by: welcher's profile welcher
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.7.2
Component: Menus Keywords: has-patch
Focuses: administration Cc:


On line 434 of nav-menu.php, the nav_menu_items_{$post_type_name}_recent filter is passing the base $args rather than the adjusted $recent_args set on line 418. Could be expected, but seemed odd to me and I ended up reapplying those arguments in my filter function.

If someone can confirm this is a bug and not as expected, I'd be happy to attach a patch.

Attachments (2)

39849.diff (944 bytes) - added by welcher 7 years ago.
39849.2.diff (1.0 KB) - added by welcher 7 years ago.
Adding recent_args as a fourth param

Download all attachments as: .zip

Change History (9)

#1 @welcher
7 years ago

  • Focuses administration added
  • Keywords needs-patch added

@eclev91 thanks for reporting!

This does seem unexpected to me as well. It seems to me that the filter should have all of the args available to it.

This ticket was mentioned in Slack in #core by welcher. View the logs.

7 years ago

7 years ago

#3 follow-up: @welcher
7 years ago

@eclev91 I've added an initial patch and @johnbillion reviewed it with me.

The concern with my approach is that $args['walker'] is overridden after the array merge and doesn't exist in the $recent_args array. We both agreed that it may be better to add a fourth argument to the filter that holds $recent_args instead.

Would you like to apply those changes?

Version 0, edited 7 years ago by welcher (next)

#4 in reply to: ↑ 3 @eclev91
7 years ago

While it's been a while since I ran into this, I think the proposed solution makes sense. As long as those arguments are available and how to get them is documented.

7 years ago

Adding recent_args as a fourth param

#5 @welcher
7 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Review to 4.9
  • Owner set to welcher
  • Status changed from new to assigned

This ticket was mentioned in Slack in #core by welcher. View the logs.

7 years ago

#7 @SergeyBiryukov
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 41941:

Menus: Pass $recent_args parameter to nav_menu_items_{$post_type_name}_recent filter.

Props welcher, eclev91.
Fixes #39849.

Note: See TracTickets for help on using tickets.