#62818 closed defect (bug) (fixed)
Walker_Nav_Menu duplicated queries introduced by get_privacy_policy_url() call
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | 6.2 |
Component: | Menus | Keywords: | has-patch commit |
Focuses: | performance | Cc: |
Description
The start_el() method in Walker_Nav_Menu currently calls get_privacy_policy_url() for every menu item when building menus. This results in redundant queries, particularly for menus with many items.
if ( get_privacy_policy_url() === $menu_item->url ) {
$atts['rel'] = empty( $atts['rel'] ) ? 'privacy-policy' : $atts['rel'] . ' privacy-policy';
}
get_privacy_policy_url should be memoized and called outside of this scope because it will be triggered for each element when building menus, resulting in tons of duplicated queries
Attachments (1)
Change History (18)
This ticket was mentioned in PR #8140 on WordPress/wordpress-develop by @arzola.
2 months ago
#1
- Keywords has-patch added; needs-patch removed
2 months ago
#3
I just fixed the tests behaviour, they were running well in isolation but failing when running all
#4
@
2 months ago
Ok false alarm I need to work the tests changes because they run well on isolation but when the entire tests suite is running they fail, not sure what I'm doing wrong
2 months ago
#6
Thank you @westonruter I'm kinda lost what's the next step hahaha, should I open a SVN PR?, not sure what to do
@westonruter commented on PR #8140:
2 months ago
#7
Ah, the next step is for a committer to take your code and commit to SVN. So your work here is done!
#10
@
2 months ago
@arzola FYI: There's no harm in attaching the patch to a ticket, but in reality it's easier to just use the PR directly. So you can skip having to do that in the future. Thanks!
The start_el() method in Walker_Nav_Menu currently calls get_privacy_policy_url() for every menu item when building menus. This results in redundant queries, particularly for menus with many items. This patch memoizes the get_privacy_policy_url() result, improving performance while maintaining existing functionality.