diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-09-03 19:06:55 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-09-03 19:06:55 +0000 |
commit | 6f0d1797b552a3a09a1b559f46955ee9b8aae7ae (patch) | |
tree | b2a7e507e6c2b4db422d7f0706000af615b1b9e0 /includes/database/select.inc | |
parent | 13ff244505e8d13411c8acb5cd70bf02ed33eb56 (diff) | |
download | brdo-6f0d1797b552a3a09a1b559f46955ee9b8aae7ae.tar.gz brdo-6f0d1797b552a3a09a1b559f46955ee9b8aae7ae.tar.bz2 |
- Patch #886970 by jhodgdon, Crell, Damien Tournoud: DB API putting wrong db placeholders in complex queries.
Diffstat (limited to 'includes/database/select.inc')
-rw-r--r-- | includes/database/select.inc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/includes/database/select.inc b/includes/database/select.inc index d46abefdf..b4f14c983 100644 --- a/includes/database/select.inc +++ b/includes/database/select.inc @@ -1125,7 +1125,21 @@ class SelectQuery extends Query implements SelectQueryInterface { } drupal_alter($hooks, $query); } - return $this->prepared = TRUE; + + $this->prepared = TRUE; + + // Now also prepare any sub-queries. + foreach ($this->tables as $table) { + if ($table['table'] instanceof SelectQueryInterface) { + $table['table']->preExecute(); + } + } + + foreach ($this->union as $union) { + $union['query']->preExecute(); + } + + return $this->prepared; } public function execute() { @@ -1411,6 +1425,13 @@ class SelectQuery extends Query implements SelectQueryInterface { // WHERE if (count($this->where)) { + // The following line will not generate placeholders correctly if there + // is a subquery. Fortunately, it is also called from getArguments() first + // so it's not a problem in practice... unless you try to call __toString() + // before calling getArguments(). That is a problem that we will have to + // fix in Drupal 8, because it requires more refactoring than we are + // able to do in Drupal 7. + // @todo Move away from __toString() For SelectQuery compilation at least. $this->where->compile($this->connection, $this); // There is an implicit string cast on $this->condition. $query .= "\nWHERE " . $this->where; |