@trigger_error('Passing a \'transactions\' connection option to '.__METHOD__.' is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745',E_USER_DEPRECATED);
@@ -1278,9 +1274,6 @@ public function rollBack($savepoint_name = 'drupal_transaction') {
* @see \Drupal\Core\Database\Transaction
*/
publicfunctionpushTransaction($name){
if(!$this->supportsTransactions()){
return;
}
if(isset($this->transactionLayers[$name])){
thrownewTransactionNameNonUniqueException($name." is already in use.");
}
...
...
@@ -1311,9 +1304,6 @@ public function pushTransaction($name) {
* @see \Drupal\Core\Database\Transaction
*/
publicfunctionpopTransaction($name){
if(!$this->supportsTransactions()){
return;
}
// The transaction has already been committed earlier. There is nothing we
// need to do. If this transaction was part of an earlier out-of-order
// rollback, an exception would already have been thrown by
...
...
@@ -1494,9 +1484,15 @@ public function clientVersion() {
*
* @return bool
* TRUE if this connection supports transactions, FALSE otherwise.
*
* @deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database
* drivers must support transactions.
*
* @see https://www.drupal.org/node/2278745
*/
publicfunctionsupportsTransactions(){
return$this->transactionSupport;
@trigger_error(__METHOD__.' is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745',E_USER_DEPRECATED);
@@ -117,6 +118,22 @@ public function testConnectionOptions() {
$this->assertNotEqual($connection_info['default']['database'],$connectionOptions['database'],'The test connection info database does not match the current connection options database.');
}
/**
* Tests the deprecation of the 'transactions' connection option.
*
* @group legacy
* @expectedDeprecation Passing a 'transactions' connection option to Drupal\Core\Database\Connection::__construct is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745
* @expectedDeprecation Drupal\Core\Database\Connection::supportsTransactions is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. All database drivers must support transactions. See https://www.drupal.org/node/2278745
// Database engines that don't support transactions can leave partial
// inserts in place when an error occurs. This is the case for MySQL
// when running on a MyISAM table.
$this->pass("The whole transaction has not been rolled-back when a duplicate key insert occurs, this is expected because the database doesn't support transactions");
}
else{
$this->fail('The whole transaction is rolled back when a duplicate key insert occurs.');
}
}
else{
$this->pass('The whole transaction is rolled back when a duplicate key insert occurs.');
}
// Ensure the other values were not inserted.
$record=$this->connection->select('test')
// Ensure the whole transaction is rolled back when a duplicate key
// Database engines that don't support transactions can leave partial
// inserts in place when an error occurs. This is the case for MySQL
// when running on a MyISAM table.
$this->pass("The whole transaction has not been rolled-back when a duplicate key insert occurs, this is expected because the database doesn't support transactions");
}
else{
$this->fail('The whole transaction is rolled back when a duplicate key insert occurs.');
}
}
else{
$this->pass('The whole transaction is rolled back when a duplicate key insert occurs.');
}
// Ensure the values for records 2 and 3 were not inserted.
$record=$this->connection->select('test')
// Ensure the whole transaction is rolled back when a duplicate key