Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy_load_term_meta query param is always true #60

Open
nickdaugherty opened this issue Oct 26, 2017 · 0 comments
Open

lazy_load_term_meta query param is always true #60

nickdaugherty opened this issue Oct 26, 2017 · 0 comments

Comments

@nickdaugherty
Copy link
Contributor

Due to how WP_Query initializes default query parameters, and ES WP Query's interaction with WP Query, the lazy_load_term_meta param ends up always being set to true when the internal query to fetch posts by id runs.

This ends up triggering get_the_terms() excessively, which leads to high numbers of cache and/or db reads.

The problem can be most readily seen by watching the $q var here:

$q = $query->query = $this->original_query_args;
$query->parse_query();
$q = array_merge( $current_query_vars, $q );

Before $query->parse_query(); is run, lazy_load_term_meta is still false...yet after it has flipped to true.

As a workaround, it can be bypassed with a filter like this:

add_filter( 'pre_get_posts', function( &$query ) {
   $query->set( 'lazy_load_term_meta', false );

   return $query;
}, 9999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant