Issue Task Closed

#104561Use TYPO3 Connection in transactional

Stefan Froemken 08/06/24, 18:53 updated 12/02/25, 14:33

Description

Hello,

I just found method Connection::transactional(). You can use it like that:

$connection = GeneralUtility::makeInstance(ConnectionPool::class)
    ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);

$queryResult = $connection->transactional(function (\Doctrine\DBAL\Connection $transactionalConnection) use ($sql): ?Result {
    try {
        $transactionalConnection->executeStatement('SET profiling=1;');
        $transactionalConnection->executeQuery($sql);
        return $transactionalConnection->executeQuery('SHOW profile;');
    } catch (Exception $e) {
    }
    return null;
});

As you see you have to use the Doctrine Connection object within the Callable. Else phpstan will fail.

What do you think? Can we implement our own interpretation of transactional into TYPO3 Connection where the Callables argument is of type TYPO3 Connection?

Nice greeting

Stefan

Reviews 2

History 711

  1. Stefan Bürk commented and changed assigned to Stefan Bürk 08/08/24, 09:36

    will have a look into that.

  2. Benni Mack changed target version 10/15/24, 08:19

  3. Gerrit Code Review pushed patch set 1 for main to change 87675 status New Under Review 01/09/25, 11:49

  4. Stefan Bürk changed tracker Feature Task PHP Version 8.3 8.1 TYPO3 Version 12 01/09/25, 11:49

  5. Stefan Bürk commented 01/09/25, 11:49

    Changed this from a feature to a task.

  6. Gerrit Code Review pushed patch set 2 for main to change 87675 01/09/25, 12:12

  7. Gerrit Code Review pushed patch set 3 for main to change 87675 01/09/25, 19:16

  8. Gerrit Code Review pushed patch set 1 for 13.4 to change 87693 01/10/25, 13:07

  9. Stefan Bürk commented and changed status Under Review Resolved done 0 % 100 % 01/10/25, 13:20

    Applied in changeset commit:dd1a1d19899d67946d4f183ddb147637e8baf6d2.

  10. Stefan Bürk changed Related to #105913 01/10/25, 15:13

  11. Benni Mack changed status Resolved Closed 12/02/25, 14:33