diff --git a/core/lib/Drupal/Core/Database/Query/InsertBase.php b/core/lib/Drupal/Core/Database/Query/InsertBase.php index 156dc19..57c26f2 100644 --- a/core/lib/Drupal/Core/Database/Query/InsertBase.php +++ b/core/lib/Drupal/Core/Database/Query/InsertBase.php @@ -55,6 +55,10 @@ /** * Adds a set of field->value pairs to be inserted. * + * This method may only be called once. Calling it a second time will be + * ignored. To queue up multiple sets of values to be inserted at once, + * use the values() method. + * * @param array $fields * An array of fields on which to insert. This array may be indexed or * associative. If indexed, the array is taken to be the list of fields. @@ -69,9 +73,9 @@ * The called object. */ public function fields(array $fields, array $values = array()) { - if (!$this->insertFields) { - if (!$values) { - if (!is_numeric(array_keys($fields)[0])) { + if (empty($this->insertFields)) { + if (empty($values)) { + if (!is_numeric(key($fields))) { $values = array_values($fields); $fields = array_keys($fields); } @@ -81,6 +85,7 @@ public function fields(array $fields, array $values = array()) { $this->insertValues[] = $values; } } + return $this; }