Project

General

Profile

Actions

Feature #82619

closed

Equivalent of old DatabaseConnection hooks in the new DBAL

Added by Saskia Schreiber over 6 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2017-09-29
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

Is there a chance to get an equivalent to the old postProcessAction hooks in the new Connection class?

I'm aware of the ConnectionPool wrapperClass feature, however this is not a solution extensions could use (think of search indexers, third-party interfaces etc.).
Doctrine itself also does not provide an entry point - only via Loggers, quite uncomfortable as the query is already parsed there.

Actions #1

Updated by Mathias Brodala over 6 years ago

  • Subject changed from Equivalent of old DatabaseConnection hooks for the new Connection class to Equivalent of old DatabaseConnection hooks in the new DBAL
Actions #2

Updated by Saskia Schreiber over 6 years ago

  • Description updated (diff)
Actions #3

Updated by Mathias Schreiber over 6 years ago

Can you describe the usecase in a bit more detail?

Actions #4

Updated by Saskia Schreiber over 6 years ago

Mathias Schreiber wrote:

Can you describe the usecase in a bit more detail?

In my case, I need to track inserts/updates to the database so I can later update the corresponding records in Elasticsearch (it's a search extension).
Updates could be made through DataHandler, Extbase or even a custom QueryBuilder query, so the Connection class is the only point where I can be sure to track everything.

As I mentioned, I previously used the DatabaseConnection hooks in TYPO3 7 and was quite surprised that there is no way to do the same thing in V8.

Actions #5

Updated by Franz Koch about 6 years ago

I'm facing the very same issue as Saskia. I need to migrate a 7.6 based website to 8.7 and heavily depend on the old hooks in order to apply custom permission checks for which I have to alter the Query itself.

Here is a description to my scenario:

I have like 10 different extensions that provide content. This content is provided in several ways to customers of my client, so that they can enrich their website with it. The content is grouped into various packages (multiple packages by content type) by my client, and his customers can book/rent those packages. The underlying booking logic is generic and can be applied to any extension (regardless of custom ones or ones from TER). Until now, I've been using the hooks in DatabaseConnection to manipulate the queries on the fly, when booking restrictions had to apply. For this, I added JOINs and additional constraints to only return allowed content that has been booked by the customer. And since queries could happen from either Extbase or the Typo3 backend (flexforms, ...), the lowest common entry point have been the hooks in DatabaseConnection and this worked just fine. Right now I have no way to achieve any of it.

To get this functionality back, I think it would be sufficient to add a "pre" and "post" hook to QueryBuilder->execute() and pass the QueryBuilder object along for manipulation. For now, I guess I have to XCLASS and add those hooks/signals myself. If you guys think those hooks would also be suiteable for the core, I could create a PR.

Actions #6

Updated by Benni Mack over 2 years ago

  • Status changed from New to Needs Feedback

In such cases we have successfully used a custom connection with the wrapper class to intercept this. This is also the recommended way from Doctrine DBAL - configuring such a class like $GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']['Default']['wrapperClass']

Actions #7

Updated by Benni Mack over 2 years ago

  • Status changed from Needs Feedback to Closed
Actions

Also available in: Atom PDF