Project

General

Profile

Actions

Task #104561

closed

Use TYPO3 Connection in transactional

Added by Stefan Froemken 5 months ago. Updated 3 days ago.

Status:
Resolved
Priority:
Should have
Assignee:
Category:
Database API (Doctrine DBAL)
Start date:
2024-08-06
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
Complexity:
easy
Sprint Focus:

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


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #105913: Use correct test fixture extension version constraintsResolvedStefan Bürk2025-01-10

Actions
Actions #1

Updated by Stefan Bürk 5 months ago

  • Assignee set to Stefan Bürk

will have a look into that.

Actions #2

Updated by Benni Mack 3 months ago

  • Target version changed from 13.3 to Candidate for Major Version
Actions #3

Updated by Gerrit Code Review 4 days ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87675

Actions #4

Updated by Stefan Bürk 4 days ago

  • Tracker changed from Feature to Task
  • PHP Version changed from 8.3 to 8.1
  • TYPO3 Version set to 12
Actions #5

Updated by Stefan Bürk 4 days ago

Changed this from a feature to a task.

Actions #6

Updated by Gerrit Code Review 4 days ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87675

Actions #7

Updated by Gerrit Code Review 4 days ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87675

Actions #8

Updated by Gerrit Code Review 3 days ago

Patch set 1 for branch 13.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/87693

Actions #9

Updated by Stefan Bürk 3 days ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #10

Updated by Stefan Bürk 3 days ago

  • Related to Task #105913: Use correct test fixture extension version constraints added
Actions

Also available in: Atom PDF