function Transaction::__destruct

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Database/Transaction.php \Drupal\Core\Database\Transaction::__destruct()
  2. 8.9.x core/lib/Drupal/Core/Database/Transaction.php \Drupal\Core\Database\Transaction::__destruct()
  3. 11.x core/lib/Drupal/Core/Database/Transaction.php \Drupal\Core\Database\Transaction::__destruct()

File

core/lib/Drupal/Core/Database/Transaction.php, line 91

Class

Transaction
A wrapper class for creating and managing database transactions.

Namespace

Drupal\Core\Database

Code

public function __destruct() {
  if ($this->connection
    ->transactionManager()) {
    $this->connection
      ->transactionManager()
      ->unpile($this->name, $this->id);
    return;
  }
  // Start of BC layer.
  // If we rolled back then the transaction would have already been popped.
  // @phpstan-ignore-next-line
  if (!$this->rolledBack) {
    // @phpstan-ignore-next-line
    $this->connection
      ->popTransaction($this->name);
  }
  // End of BC layer.
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.