function TransactionManagerBase::commitAll

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php \Drupal\Core\Database\Transaction\TransactionManagerBase::commitAll()
  2. 10 core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php \Drupal\Core\Database\Transaction\TransactionManagerBase::commitAll()

Commits the entire transaction stack.

@internal This method exists only to work around a bug caused by Drupal incorrectly relying on object destruction order to commit transactions. Xdebug 3.3.0 changes the order of object destruction when the develop mode is enabled.

Deprecated

in drupal:11.5.0 and is removed from drupal:13.0.0. There is no replacement.

See also

https://www.drupal.org/node/3524461

File

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

Class

TransactionManagerBase
The database transaction manager base class.

Namespace

Drupal\Core\Database\Transaction

Code

public function commitAll() : void {
  // Only soft deprecation (no @trigger_error) to avoid thousands of
  // occurrences per test run. PHPStan reports usage errors anyway.
  if ($this->stackDepth() !== 0) {
    @trigger_error('Committing transactions via ' . __METHOD__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:13.0.0. There is no replacement. See https://www.drupal.org/node/3524461', E_USER_DEPRECATED);
  }
  foreach (array_reverse($this->stack()) as $id => $item) {
    $this->unpile($item->name, $id);
  }
  // Run post-transaction callbacks now (while Connection is still valid).
  // Prevents destructor-order bug: Connection::__destruct can run before
  // Transaction::__destruct, leaving PDO null when callbacks run.
  $this->processPostTransactionCallbacks();
}

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