Make WordPress Core

Ticket #42691: 42691.diff

File 42691.diff, 1.3 KB (added by GM_Alex, 7 years ago)
  • src/wp-includes/class-wp-term-query.php

    diff --git a/src/wp-includes/class-wp-term-query.php b/src/wp-includes/class-wp-term-query.php
    index e27b686..829069b 100644
    a b class WP_Term_Query { 
    288288                return $this->get_terms();
    289289        }
    290290
     291    /**
     292     * Maps the term id array to real term objects.
     293     *
     294     * @param array $terms
     295     *
     296     * @return array
     297     */
     298    private function map_terms( array $terms ) {
     299        $terms = array_map( 'get_term', $terms );
     300
     301        // TODO change to anonymous functions if WordPress drops 5.2 support
     302        return array_filter($terms, create_function('$value', 'return $value !== null;'));
     303    }
     304
    291305        /**
    292306         * Get terms, based on query_vars.
    293307         *
    class WP_Term_Query { 
    677691                $cache = wp_cache_get( $cache_key, 'terms' );
    678692                if ( false !== $cache ) {
    679693                        if ( 'all' === $_fields ) {
    680                                 $cache = array_map( 'get_term', $cache );
     694                $cache = $this->map_terms( $cache );
    681695                        }
    682696
    683697                        $this->terms = $cache;
    class WP_Term_Query { 
    809823                wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS );
    810824
    811825                if ( 'all' === $_fields || 'all_with_object_id' === $_fields ) {
    812                         $terms = array_map( 'get_term', $terms );
     826                        $terms = $this->map_terms( $terms );
    813827                }
    814828
    815829                $this->terms = $terms;