TransactionManagerBase::$stack

Same name in other branches
  1. 10 core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php \Drupal\Core\Database\Transaction\TransactionManagerBase::stack

The stack of Drupal transactions currently active.

This property is keeping track of the Transaction objects started and ended as a LIFO (Last In, First Out) stack.

The database API allows to begin transactions, add an arbitrary number of additional savepoints, and release any savepoint in the sequence. When this happens, the database will implicitly release all the savepoints created after the one released. Given Drupal implementation of the Transaction objects, we cannot force reducing the scope of the corresponding Transaction savepoint objects from the manager, because they live in the scope of the calling code. This stack ensures that when an outlived Transaction object gets out of scope, it will not try to release on the database a savepoint that no longer exists.

Differently, rollbacks are strictly being checked for LIFO order: if a rollback is requested against a savepoint that is not the last created, the manager will throw a TransactionOutOfOrderException.

The array key is the transaction's unique id, its value a StackItem.

Type: array

File

core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php, line 70

Class

TransactionManagerBase
The database transaction manager base class.

Namespace

Drupal\Core\Database\Transaction

Code

private array $stack = [];

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