alleyinteractive / alleyinteractive/es-wp-query
lazy_load_term_meta query param is always `true`
- 主要語言
- PHP
- 星號
- 125
- 分支
- 28
- PR 合併指標
- 30 天內沒有已合併 PR
描述
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 );
```
貢獻指南
評估
這個 Issue 還沒有評估資料。