API / Minn\Runtime / TermQueryRunner

TermQueryRunner final class

Minn\Runtime\TermQueryRunner · public/minn/src/Minn/Runtime/TermQueryRunner.php · 299 lines

WP_Term_Query::get_terms as the reference runs it (probe wp-term-query-sql): the variables parsed and handed to pre_get_terms, get_terms_args, the WHERE pieces (taxonomies, inclusions, exclusions with excluded trees and childless terms through list_terms_exclusions, names, slugs, term taxonomy ids, likes, objects, parent, counts, search, meta), the order through get_terms_orderby, the fields through get_terms_fields, all of it through terms_clauses, terms_pre_query, and the results shaped by TermQueryTree (children, padded counts, the empty hidden, the page). A request's rows are kept for the rest of the request, as the reference keeps them in its object cache, until a term table is written; a lookup the engine can answer from what it has read (QueryAnswers) runs no SQL.

Constants and properties

privateSHAPING = array ( 0 => 'get_terms_defaults', 1 => 'parse_term_query', 2 => 'get_terms_args', 3 => 'get_terms_orderby', 4 => 'list_terms_exclusions', 5 => 'get_terms_fields', 6 => 'terms_clauses', 7 => 'terms_pre_query', )

The filters that shape the request: an engine answer stands only while none of them has a listener.

privateMinn\Objects\TermsQuery $query
privateobject $wpdb
privatearray $where
privatebool $renamed

Whether saving's sanitising changed a name the query looks up (the answer then no longer fits it).

Public

methodrun(Minn\Objects\TermsQuery $query, object $wpdb): mixed#

Runs a term query object's variables: its terms in the shape the fields ask for, a count, or what a plugin answered first.

$wpdbobjectthe database object plugins see

Internals 14

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateanswered(?Closure $answer): ?array#

The rows an engine answer gives (term ids as rows), when the query is still the one the engine wrote; null when it is not, or it has none.

@return list<object>|null
privatekept(string $kind, Closure $read): mixed#

A request's answer read once a request: rows (each a copy, so a caller's changes stay its own) or a count.

$readClosure(): mixed
privatelists(array $args): array#

Names, slugs, term taxonomy ids and object ids as lists, as the reference holds them once plugins have had the arguments.

$argsarray<string, mixed>
@return array<string, mixed>
privatehierarchical(array $args): bool#

Whether the results have a tree to walk (a count never does). @param array<string, mixed> $args

$argsarray<string, mixed>
privatesettle(array $args, array $taxonomies): array#

The variables pre_get_terms left, settled: a flat taxonomy needs no tree, a parent overrides child_of, `get=all` asks for every term; then get_terms_args.

$argsarray<string, mixed>
$taxonomieslist<string>
@return array<string, mixed>
privateinHierarchy(int $parent, array $taxonomies): bool#

Whether a parent or child_of term has children in any of the taxonomies (when none, the query is not run). @param list<string> $taxonomies

$taxonomieslist<string>
privateorder(array $args): array#

The ORDER BY clause and direction, term_order needing the relationships. @param array<string, mixed> $args @return array{0: string, 1: string}

$argsarray<string, mixed>@return array{0: string, 1: string}
privateclauses(array $args, array $taxonomies): void#

The WHERE pieces, by name, in the reference's order. @param array<string, mixed> $args @param list<string> $taxonomies

$argsarray<string, mixed>@param list<string> $taxonomies
privateexclusions(array $args, array $taxonomies): string#

The excluded ids (an excluded term's whole tree, childless terms' parents), unless ids are included. @param array<string, mixed> $args @param list<string> $taxonomies

$argsarray<string, mixed>@param list<string> $taxonomies
privatenames(array $args, array $taxonomies): void#

Names (as saving stores them), slugs and term taxonomy ids. @param array<string, mixed> $args @param list<string> $taxonomies

$argsarray<string, mixed>@param list<string> $taxonomies
privatelikes(array $args): void#
$argsarray<string, mixed>
privateselect(array $args, array $taxonomies, string $orderby, string $order): void#

The rest of the WHERE (counts, search, meta), the fields, the joins, terms_clauses, and the request written from what it returned.

$argsarray<string, mixed>
$taxonomieslist<string>
privatelimits(array $args): string#

A LIMIT only when no tree has to be walked first (the tree's page is cut afterwards). @param array<string, mixed> $args

$argsarray<string, mixed>
privatemeta(): array#

The meta query's join and WHERE piece, read again in case pre_get_terms changed its variables. @return array{0: string, 1: string}

@return array{0: string, 1: string}