[wp-trac] [WordPress Trac] #62818: Walker_Nav_Menu duplicated queries introduced by get_privacy_policy_url() call
WordPress Trac
noreply at wordpress.org
Fri Jan 17 03:41:33 UTC 2025
#62818: Walker_Nav_Menu duplicated queries introduced by get_privacy_policy_url()
call
--------------------------+-----------------------------
Reporter: arzola | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: 6.7.1
Severity: normal | Keywords: needs-patch
Focuses: performance |
--------------------------+-----------------------------
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.
{{{
#!php
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
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62818>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list