Feature #82619
closedEquivalent of old DatabaseConnection hooks in the new DBAL
0%
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.
Updated by Mathias Brodala about 7 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
Updated by Mathias Schreiber about 7 years ago
Can you describe the usecase in a bit more detail?
Updated by Saskia Schreiber about 7 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.
Updated by Franz Koch over 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.
Updated by Benni Mack over 3 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']
Updated by Benni Mack about 3 years ago
- Status changed from Needs Feedback to Closed
I've put an example online: https://gist.github.com/bmack/55a167e173313aa5aff2c59fead83082