Ticket #34047: 34047.patch
File 34047.patch, 3.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/default-filters.php
201 201 add_filter( 'xmlrpc_pingback_error', 'xmlrpc_pingback_error' ); 202 202 add_filter( 'title_save_pre', 'trim' ); 203 203 add_filter( 'get_comment_metadata', 'wp_lazyload_comment_meta', 10, 2 ); 204 add_filter( 'get_term_metadata', 'wp_lazyload_term_meta', 10, 2 );204 add_filter( 'get_term_metadata', 'wp_lazyload_term_meta', 99, 2 ); 205 205 206 206 add_filter( 'http_request_host_is_external', 'allowed_http_request_hosts', 10, 2 ); 207 207 -
src/wp-includes/taxonomy-functions.php
1581 1581 * As a rule, term queries (`get_terms()` and `wp_get_object_terms()`) prime the metadata cache for matched terms by 1582 1582 * default. However, this can cause a slight performance penalty, especially when that metadata is not actually used. 1583 1583 * In the context of a `WP_Query` loop, we're able to avoid this potential penalty. `update_object_term_cache()`, 1584 * called from `update_post_caches()`, does not 'update_term_meta_cache'. Instead, the first time `get_term_meta()` is 1585 * called from within a `WP_Query` loop, the current function detects the fact, and then primes the metadata cache for 1586 * all terms attached to all posts in the loop, with a single database query. 1584 * called from `update_post_caches()`, does not `update_termmeta_cache()`. Instead, the first time `get_term_meta()` is 1585 * called from within a `WP_Query` loop, the current function detects the fact, and then primes the metadata cache. 1587 1586 * 1588 1587 * @since 4.4.0 1589 1588 * 1590 * @param null $check The `$check` param passed from the 'pre_term_metadata' hook.1589 * @param mixed $check The `$check` param passed from the 'get_term_metadata' hook. 1591 1590 * @param int $term_id ID of the term whose metadata is being cached. 1592 * @return null In order not to short-circuit `get_metadata()`.1591 * @return mixed The original value of `$check`. 1593 1592 */ 1594 1593 function wp_lazyload_term_meta( $check, $term_id ) { 1595 1594 global $wp_query; 1596 1595 1596 // Skip if the call to `get_metadata()` will be short-circuited. 1597 if ( null === $check ) { 1598 prime_term_meta_cache( $wp_query ); 1599 } 1600 1601 return $check; 1602 } 1603 1604 /** 1605 * Prime the metadata cache for all terms attached to all posts in a WP_Query. 1606 * 1607 * @since 4.4.0 1608 * 1609 * @param WP_Query $wp_query Query object. 1610 */ 1611 function prime_term_meta_cache( $wp_query ) { 1597 1612 if ( $wp_query instanceof WP_Query && ! empty( $wp_query->posts ) && $wp_query->get( 'update_post_term_cache' ) ) { 1598 1613 // We can only lazyload if the entire post object is present. 1599 1614 $posts = array(); … … 1628 1643 update_termmeta_cache( array_keys( $term_ids ) ); 1629 1644 } 1630 1645 } 1631 1632 return $check;1633 1646 } 1634 1647 1635 1648 /**