Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#37591 closed defect (bug) (fixed)

WP_Term_Query breaks when cache is returned

Reported by: wonderboymusic's profile wonderboymusic Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.6 Priority: high
Severity: blocker Version:
Component: Taxonomy Keywords: has-patch commit
Focuses: Cc:

Description

Found this bug on NYT in production since I am running the RC there #yolo

as originally reported here:
https://wordpress.slack.com/archives/core/p1470433813002336

$cache = wp_cache_get( $cache_key, 'terms' );
if ( false !== $cache ) {
    if ( 'all' === $_fields ) {
        $cache = array_map( 'get_term', $cache );
    }
    return $cache;
}

Needs to be:

$cache = wp_cache_get( $cache_key, 'terms' );
if ( false !== $cache ) {
    if ( 'all' === $_fields ) {
        $cache = array_map( 'get_term', $cache );
    }
    $this->terms = $cache;
    return $cache;
}

Attachments (1)

37591.diff (420 bytes) - added by wonderboymusic 8 years ago.

Download all attachments as: .zip

Change History (7)

#1 @wonderboymusic
8 years ago

In 38211:

Taxononmy: add unit that shows that WP_Term_Query is broken when the query is read from the cache.

See #37591.

@wonderboymusic
8 years ago

#2 @wonderboymusic
8 years ago

  • Keywords has-patch commit added

#3 @wonderboymusic
8 years ago

In 38212:

Taxononmy: set WP_Term_Query::terms when returning terms from the cache in WP_Term_Query::get_terms().

See #37591.

#4 @ocean90
8 years ago

  • Owner set to boonebgorges
  • Status changed from new to reviewing

#5 @boonebgorges
8 years ago

  • Owner changed from boonebgorges to wonderboymusic

[38211] and [38212] look good to merge to the 4.6 branch.

#6 @ocean90
8 years ago

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

In 38214:

Taxononmy: Set WP_Term_Query::terms when returning terms from the cache in WP_Term_Query::get_terms().

Merge of [38211] and [38212] to the 4.6 branch.

Props wonderboymusic.
Props boonebgorges for review.
Fixes #37591.

Note: See TracTickets for help on using tickets.