function Select::preExecute
Same name in other branches
- 9 core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::preExecute()
- 8.9.x core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::preExecute()
- 11.x core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::preExecute()
Overrides SelectInterface::preExecute
1 call to Select::preExecute()
- Select::execute in core/
lib/ Drupal/ Core/ Database/ Query/ Select.php
File
-
core/
lib/ Drupal/ Core/ Database/ Query/ Select.php, line 462
Class
- Select
- Query builder for SELECT statements.
Namespace
Drupal\Core\Database\QueryCode
public function preExecute(?SelectInterface $query = NULL) {
// If no query object is passed in, use $this.
if (!isset($query)) {
$query = $this;
}
// Only execute this once.
if ($query->isPrepared()) {
return TRUE;
}
// Modules may alter all queries or only those having a particular tag.
if (isset($this->alterTags)) {
// Many contrib modules as well as Entity Reference in core assume that
// query tags used for access-checking purposes follow the pattern
// $entity_type . '_access'. But this is not the case for taxonomy terms,
// since the core Taxonomy module used to add term_access instead of
// taxonomy_term_access to its queries. Provide backwards compatibility
// by adding both tags here instead of attempting to fix all contrib
// modules in a coordinated effort.
// @todo Extract this mechanism into a hook as part of a public
// (non-security) issue.
// @todo Emit E_USER_DEPRECATED if term_access is used.
// https://www.drupal.org/node/2575081
$term_access_tags = [
'term_access' => 1,
'taxonomy_term_access' => 1,
];
if (array_intersect_key($this->alterTags, $term_access_tags)) {
$this->alterTags += $term_access_tags;
}
$hooks = [
'query',
];
foreach ($this->alterTags as $tag => $value) {
$hooks[] = 'query_' . $tag;
}
\Drupal::moduleHandler()->alter($hooks, $query);
}
$this->prepared = TRUE;
// Now also prepare any sub-queries.
foreach ($this->tables as $table) {
if ($table['table'] instanceof SelectInterface) {
$table['table']->preExecute();
}
}
foreach ($this->union as $union) {
$union['query']->preExecute();
}
return $this->prepared;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.