Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Database / Query / Select.php
index b3426e6d4de903ac7fc9c99064fb8ae05b7e9e74..fe88f84172873c05dd9ae233e68bd6b72b59f1b9 100644 (file)
@@ -113,6 +113,8 @@ class Select extends Query implements SelectInterface {
 
   /**
    * The FOR UPDATE status
+   *
+   * @var bool
    */
   protected $forUpdate = FALSE;
 
@@ -128,7 +130,7 @@ class Select extends Query implements SelectInterface {
    * @param array $options
    *   Array of query options.
    */
-  public function __construct($table, $alias = NULL, Connection $connection, $options = []) {
+  public function __construct($table, $alias, Connection $connection, $options = []) {
     $options['return'] = Database::RETURN_STATEMENT;
     parent::__construct($connection, $options);
     $conjunction = isset($options['conjunction']) ? $options['conjunction'] : 'AND';
@@ -156,14 +158,14 @@ class Select extends Query implements SelectInterface {
    * {@inheritdoc}
    */
   public function hasAllTags() {
-    return !(boolean)array_diff(func_get_args(), array_keys($this->alterTags));
+    return !(boolean) array_diff(func_get_args(), array_keys($this->alterTags));
   }
 
   /**
    * {@inheritdoc}
    */
   public function hasAnyTag() {
-    return (boolean)array_intersect(func_get_args(), array_keys($this->alterTags));
+    return (boolean) array_intersect(func_get_args(), array_keys($this->alterTags));
   }
 
   /**
@@ -825,9 +827,8 @@ class Select extends Query implements SelectInterface {
     }
     $query .= implode(', ', $fields);
 
-
     // FROM - We presume all queries have a FROM, as any query that doesn't won't need the query builder anyway.
-    $query .= "\nFROM ";
+    $query .= "\nFROM";
     foreach ($this->tables as $table) {
       $query .= "\n";
       if (isset($table['join type'])) {
@@ -913,6 +914,8 @@ class Select extends Query implements SelectInterface {
    * {@inheritdoc}
    */
   public function __clone() {
+    parent::__clone();
+
     // On cloning, also clone the dependent objects. However, we do not
     // want to clone the database connection object as that would duplicate the
     // connection itself.
@@ -922,6 +925,11 @@ class Select extends Query implements SelectInterface {
     foreach ($this->union as $key => $aggregate) {
       $this->union[$key]['query'] = clone($aggregate['query']);
     }
+    foreach ($this->tables as $alias => $table) {
+      if ($table['table'] instanceof SelectInterface) {
+        $this->tables[$alias]['table'] = clone $table['table'];
+      }
+    }
   }
 
 }