Feature #82619
closed
Equivalent of old DatabaseConnection hooks in the new DBAL
Added by Saskia Schreiber about 7 years ago.
Updated about 3 years ago.
Category:
Database API (Doctrine DBAL)
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.
- Subject changed from Equivalent of old DatabaseConnection hooks for the new Connection class to Equivalent of old DatabaseConnection hooks in the new DBAL
- Description updated (diff)
Can you describe the usecase in a bit more detail?
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.
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.
- 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']
- Status changed from Needs Feedback to Closed
Also available in: Atom
PDF