The new purge() method is missing from \Drupal\Core\Database\Transaction\TransactionManagerInterface

Created on 3 August 2025, 15 days ago

Problem/Motivation

In โœจ Allow explicit COMMIT in Transaction objects Active , a purge() method was added to the \Drupal\Core\Database\Transaction\TransactionManagerBase class but not to its interface, TransactionManagerInterface. However, \Drupal\Core\Database\Transaction::__destruct() still assumes that that method will always be present for all transaction managers, leading to a fatal error if this is not the case.

While this seems very theoretical at first glance (why would any transaction manager not sub-class TransactionManagerBase?), this has real consequences for tests which suddenly break because the default returned by a mocked Connection::transactionManager() will just be a mock object for TransactionManagerInterface and, thus, missing the purge() method. See #3523808-12: Fix failing pipelines โ†’ for an example where this happened.

The problem is compounded by the fact that the __destruct() method will only be called once the test run is finished, at which point not even a manually added mock for Connection::transactionManager() will be used anymore (by default).

Steps to reproduce

I think having any test that mocks a \Drupal\Core\Database\Transaction object will suffice to reproduce this, failing with a fatal error after this recent change.

Proposed resolution

Add the purge() method to the \Drupal\Core\Database\Transaction\TransactionManagerInterface unless this was specifically not done for a good reason.

Remaining tasks

  • Decide on a solution
  • Implement it
  • Write a regression test

User interface changes

None.

Introduced terminology

None.

API changes

Added method \Drupal\Core\Database\Transaction\TransactionManagerInterface::purge(), but this should be fine with our BC policy since the method exists on the associated base class.

Data model changes

None.

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

database system

Created by

๐Ÿ‡ฆ๐Ÿ‡นAustria drunken monkey Vienna, Austria

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024