PostQuery final class
Minn\Runtime\PostQuery · public/minn/src/Minn/Runtime/PostQuery.php · 425 lines
WP_Query::get_posts as the reference runs it (probe wp-query-sql): the variables parsed and handed to pre_get_posts, the clauses written piece by piece, every filter a plugin may change them through in the reference's order (suppress_filters keeps the ones it keeps), the request split into an id query when that is cheaper, the count, a single post's status check and preview, sticky posts on the home listing, and the results filters. A lookup the engine can answer from what it has read (QueryAnswers) runs every filter and no SQL, unless a plugin changes it.
Constants and properties
| private | SHAPING = array ( 0 => 'parse_query', 1 => 'parse_tax_query', 2 => 'posts_search', 3 => 'posts_search_orderby', 4 => 'posts_where', 5 => 'posts_join', 6 => 'posts_where_paged', 7 => 'posts_groupby', 8 => 'posts_join_paged', 9 => 'posts_orderby', 10 => 'posts_distinct', 11 => 'post_limits', 12 => 'posts_fields', 13 => 'posts_clauses', 14 => 'posts_where_request', 15 => 'posts_groupby_request', 16 => 'posts_join_request', 17 => 'posts_orderby_request', 18 => 'posts_distinct_request', 19 => 'posts_fields_request', 20 => 'post_limits_request', 21 => 'posts_clauses_request', 22 => 'posts_request', 23 => 'posts_pre_query', 24 => 'split_the_query', 25 => 'posts_request_ids', ) | The hooks that shape the request: an engine answer stands only while none of them has a listener. |
| private | Minn\Objects\Query $query | |
| private | object $wpdb | |
| private | Minn\Runtime\PostQueryParts $parts | |
| private | ?Closure $answer | |
| private | readonly Minn\Db $db | Promoted from the constructor. |
Public
| new | __construct(Minn\Db $db)# | |||||||
| method | run(Minn\Objects\Query $query, object $wpdb, mixed $urlSearch): mixed# | Runs a query object's variables and fills it in: the posts (or ids, or id => parent), the request, the counts. Returns what get_posts returns.
| ||||||
| method | search(Minn\Objects\Query $query, array $q, mixed $urlSearch): string# | A search's WHERE fragment, settling the search variables (the terms, how many the string split into, the title matches its order ranks by).
| ||||||
| method | stopwords(): array# | The search stopwords, translated and filtered. @return list<string> @return list<string> |
Internals 14
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | prepare(): void# | Parses the variables, hands them to pre_get_posts, and reads the meta query from them. | |||
| private | defaults(array $q): void# | The defaults get_posts settles before it writes a clause. @param array<string, mixed> $q
| |||
| private | pageSize(array $q): void# | posts_per_page from the option, showposts, an archive's own size or the feed's, and nopaging. @param array<string, mixed> $q
| |||
| private | clauses(array $q, mixed $urlSearch): void# | Writes the clauses, in the reference's order. @param array<string, mixed> $q
| |||
| private | taxonomies(array $q): void# | The tax query's clauses (not for a single post), a taxonomy archive's types, and the compatibility variables. @param array<string, mixed> $q
| |||
| private | searchOrder(array $q): void# | A search's relevance order, ahead of the order asked for, when no other order is asked for. @param array<string, mixed> $q
| |||
| private | filtered(array $q): void# | The clause filters, paging between the first two and the rest, and posts_selection. @param array<string, mixed> $q
| |||
| private | through(array $hooks, string $clausesHook): void# | Each piece through its filter, then all seven through the clauses filter. @param array<string, string> $hooks
| |||
| private | paging(array $q): void# | LIMIT for a listing that pages: the offset when one is given, the page's start otherwise. @param array<string, mixed> $q
| |||
| private | execute(array $q): mixed# | Writes the request, runs it (or takes posts_pre_query's answer), and finishes the results. @param array<string, mixed> $q
| |||
| private | idsOnly(array $q): array# | The ids (or id => parent) a query for them returns. @param array<string, mixed> $q
| |||
| private | select(array $q, string $old, string $foundRows): void# | Runs the request: ids first, then their posts, when the query can be split that way. @param array<string, mixed> $q
| |||
| private | answered(array $q): ?array# | The ids an engine answer gives, when the query is still the one the engine wrote; null when it is not, or it has none.
@return list<int>|null | |||
| private | foundPosts(array $q): void# | found_posts (from FOUND_ROWS() when the query paged, else the posts' count) and max_num_pages. @param array<string, mixed> $q
|
Nothing matches.