Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347
This commit is contained in:
parent
2a9f1f148d
commit
fd3b12cf27
251 changed files with 5439 additions and 957 deletions
|
@ -138,7 +138,38 @@ class Connection extends DatabaseConnection {
|
|||
}
|
||||
}
|
||||
|
||||
return parent::query($query, $args, $options);
|
||||
// We need to wrap queries with a savepoint if:
|
||||
// - Currently in a transaction.
|
||||
// - A 'mimic_implicit_commit' does not exist already.
|
||||
// - The query is not a savepoint query.
|
||||
$wrap_with_savepoint = $this->inTransaction() &&
|
||||
!isset($this->transactionLayers['mimic_implicit_commit']) &&
|
||||
!(is_string($query) && (
|
||||
stripos($query, 'ROLLBACK TO SAVEPOINT ') === 0 ||
|
||||
stripos($query, 'RELEASE SAVEPOINT ') === 0 ||
|
||||
stripos($query, 'SAVEPOINT ') === 0
|
||||
)
|
||||
);
|
||||
if ($wrap_with_savepoint) {
|
||||
// Create a savepoint so we can rollback a failed query. This is so we can
|
||||
// mimic MySQL and SQLite transactions which don't fail if a single query
|
||||
// fails. This is important for tables that are created on demand. For
|
||||
// example, \Drupal\Core\Cache\DatabaseBackend.
|
||||
$this->addSavepoint();
|
||||
try {
|
||||
$return = parent::query($query, $args, $options);
|
||||
$this->releaseSavepoint();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->rollbackSavepoint();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$return = parent::query($query, $args, $options);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function prepareQuery($query) {
|
||||
|
|
|
@ -99,12 +99,25 @@ class Insert extends QueryInsert {
|
|||
elseif ($options['return'] == Database::RETURN_INSERT_ID) {
|
||||
$options['return'] = Database::RETURN_NULL;
|
||||
}
|
||||
// Only use the returned last_insert_id if it is not already set.
|
||||
if (!empty($last_insert_id)) {
|
||||
$this->connection->query($stmt, array(), $options);
|
||||
|
||||
// Create a savepoint so we can rollback a failed query. This is so we can
|
||||
// mimic MySQL and SQLite transactions which don't fail if a single query
|
||||
// fails. This is important for tables that are created on demand. For
|
||||
// example, \Drupal\Core\Cache\DatabaseBackend.
|
||||
$this->connection->addSavepoint();
|
||||
try {
|
||||
// Only use the returned last_insert_id if it is not already set.
|
||||
if (!empty($last_insert_id)) {
|
||||
$this->connection->query($stmt, array(), $options);
|
||||
}
|
||||
else {
|
||||
$last_insert_id = $this->connection->query($stmt, array(), $options);
|
||||
}
|
||||
$this->connection->releaseSavepoint();
|
||||
}
|
||||
else {
|
||||
$last_insert_id = $this->connection->query($stmt, array(), $options);
|
||||
catch (\Exception $e) {
|
||||
$this->connection->rollbackSavepoint();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// Re-initialize the values array so that we can re-use this query.
|
||||
|
|
|
@ -76,11 +76,23 @@ class NativeUpsert extends QueryUpsert {
|
|||
$options['sequence_name'] = $table_information->sequences[0];
|
||||
}
|
||||
|
||||
$this->connection->query($stmt, [], $options);
|
||||
|
||||
// Re-initialize the values array so that we can re-use this query.
|
||||
$this->insertValues = [];
|
||||
|
||||
// Create a savepoint so we can rollback a failed query. This is so we can
|
||||
// mimic MySQL and SQLite transactions which don't fail if a single query
|
||||
// fails. This is important for tables that are created on demand. For
|
||||
// example, \Drupal\Core\Cache\DatabaseBackend.
|
||||
$this->connection->addSavepoint();
|
||||
try {
|
||||
$this->connection->query($stmt, [], $options);
|
||||
$this->connection->releaseSavepoint();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->connection->rollbackSavepoint();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue