Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#40947 closed defect (bug) (fixed)

Backward compatability _sort_nav_menu_items

Reported by: piewp's profile PieWP Owned by: piewp's profile PieWP
Milestone: 5.1 Priority: normal
Severity: normal Version: 4.7
Component: Menus Keywords: good-first-bug has-patch commit
Focuses: docs Cc:

Description

The function _sort_nav_menu_items() does no longer seem to be backwards compatible. This is due to the global $_menu_item_sort_prop no longer being set.

Its sibling function wp_get_nav_menu_items() should be responsible for setting this var and in the doc also actually refers to it, codewise it does nothing with it though.

I've attached a file fixing the backwards compatibility, not quite sure what is more important though. Fixing backwards compatibility or removing/cleaning up an additional global var. Either way I suggest either the patch gets applied or the PHP doc of $_menu_item_sort_prop gets updated.

Attachments (3)

nav-menu.patch (644 bytes) - added by PieWP 7 years ago.
Patch file setting the global
40947.diff (775 bytes) - added by welcher 7 years ago.
Updated patch from root
40947.updated-doc.diff (390 bytes) - added by PieWP 7 years ago.
Updated docs to remove global usage

Download all attachments as: .zip

Change History (16)

@PieWP
7 years ago

Patch file setting the global

#1 @PieWP
7 years ago

  • Keywords has-patch 2nd-opinion added

Meant the PHPDoc of wp_get_nav_menu_items()

#2 @welcher
7 years ago

@PieWP thanks for reporting and the patch!

Typically, it's best to generate the patch from the root of the repository to allow other contributors to more-easily apply the patch. That said, we can usually figure it out :)

I have taken the liberty of regenerating the patch.

I'm not sure of the history for $_menu_item_sort_prop so I'm going to look into it a bit before commenting on re-adding it.

@welcher
7 years ago

Updated patch from root

#3 @welcher
7 years ago

  • Focuses docs added
  • Keywords needs-patch good-first-bug added; has-patch 2nd-opinion removed

@PieWP I looked into the history here and _sort_nav_menu_items was deprecated in 4.7 in favor of wp_list_sort() and it looks like all references to that global only exist in that function.

I think the fix here is to update the docs for wp_get_nav_menu_items to remove a references to the global.

@PieWP
7 years ago

Updated docs to remove global usage

#4 @PieWP
7 years ago

  • Keywords has-patch added; needs-patch removed
  • Type changed from defect (bug) to enhancement

@welcher Agreed, seem it was fixed in 4.7 anyway to no longer use the global. Added a patch file (from root) which updates the docs.

#5 @welcher
7 years ago

  • Keywords commit early added
  • Milestone changed from Awaiting Review to 5.0

#6 @welcher
7 years ago

Thanks for the patch update @PieWP. Now that we're in release candidate for 4.9, we'll have to get this into the next release.

#7 @welcher
7 years ago

  • Keywords early removed
  • Milestone changed from 5.0 to 4.9.1
  • Type changed from enhancement to defect (bug)

#8 @welcher
7 years ago

  • Owner set to PieWP
  • Status changed from new to assigned

#9 @welcher
7 years ago

@PieWP setting this back to a bug as it's an issue with the docs and assigning to you as the owner.

#10 @johnbillion
7 years ago

  • Milestone changed from 4.9.1 to 5.0

#11 @SergeyBiryukov
7 years ago

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

In 42634:

Menus: Remove $_menu_item_sort_prop global reference from wp_get_nav_menu_items(), unused since [38928].

Props PieWP, welcher.
Fixes #40947.

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


7 years ago

#13 @johnbillion
6 years ago

  • Milestone changed from 5.0 to 5.1
Note: See TracTickets for help on using tickets.