alleyinteractive / alleyinteractive/es-wp-query
lazy_load_term_meta query param is always `true`
- Lingua principale
- PHP
- Stelle
- 125
- Fork
- 28
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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:
https://github.com/alleyinteractive/es-wp-query/blob/5b6d5d093b2cba7d7a7a211638384030f909b3a4/class-es-wp-query-shoehorn.php#L218-L220
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 );
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.