-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DoctrineBridge] Allow to use a middleware instead of DbalLogger #45491
Conversation
f3dc761
to
4c4cd5a
Compare
status: needs work |
122ec76
to
0281685
Compare
status: needs review |
Hey! I think @lucasaba has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
{ | ||
$query = null; | ||
if (1 === ++$this->nestingLevel) { | ||
$this->debugDataHolder->addQuery($this->connectionName, $query = new Query('"START TRANSACTION"')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the double quotes ? They are not part of the SQL query starting a transaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for COMMIT and ROLLBACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the format that is currently used in the profiler: https://github.com/doctrine/dbal/blob/2afc6f00e8ff145ab386e9d25af293db98418bf5/src/Connection.php#L1297; should I change it anyway ?
src/Symfony/Bridge/Doctrine/Tests/DataCollector/DoctrineDataCollectorTest.php
Outdated
Show resolved
Hide resolved
@nicolas-grekas @fabpot given that this PR is about moving away from a deprecated DBAL API for the collector of the Symfony webprofiler, I suggest merging that into 5.4 rather than 6.1, so that the Symfony LTS does not use the deprecated API for years for the debug features. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All classes in the Symfony\Bridge\Doctrine\Middleware\Debug
namespace except for the middleware itself and the DebugDataHolder should be tagged @internal
. The various decorators are not meant to be reused by other code than our middleware (the DebugDataHolder needs to be wired by DoctrineBundle, which is why it cannot be internal)
2eca244
to
f660a87
Compare
status: needs review |
src/Symfony/Bridge/Doctrine/Middleware/Debug/DebugDataHolder.php
Outdated
Show resolved
Hide resolved
|
||
public function start(): void | ||
{ | ||
$this->start = microtime(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this duplicate the logic from the stopwatch? How about using the duration from the stopwatch instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stopwatch is an optional dependency of Doctrine bridge. Not using the stopwatch here allows to have durations even when stopwatch is not installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it kind of acceptable that timings are available only if the stopwatch is installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is it's currently done in this way in DebugStack. So using stopwatch instead will lead to a loss of query durations occurring on a patch version (for an application without stopwatch). WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong button… I'm getting old. 🙈
8aeaacc
to
8de3964
Compare
status: needs review |
If we don't do this already while merging up, please create that PR. |
src/Symfony/Bridge/Doctrine/Middleware/Debug/DebugDataHolder.php
Outdated
Show resolved
Hide resolved
8de3964
to
2d36823
Compare
2d36823
to
20d0806
Compare
Thank you @l-vo. |
That's a breaking change as |
Nervermind, the BC break is in DoctrineBundle 2.6. |
@fabpot there is this kind of bc layer on Doctrine bundle: https://github.com/doctrine/DoctrineBundle/blob/0620e230c6529011b305e07efa0df0678bf71a6d/DoctrineBundle.php#L67. Did I miss another thing ? |
Here is the error I get:
|
By chance, is it a project with sentry-symfony ? |
Yes, it is! |
it has been spotted on doctrine/DoctrineBundle#1485, sentry-symfony aliases an internal interface as Doctrine\DBAL\Middleware that fools the detection. Accorded to the issue in DoctrineBundle, it won't be fixed on DoctrineBundle side. From @dmaicher:
|
Fixed on sentry-symfony side by getsentry/sentry-symfony#608 |
…g middlewares (l-vo) This PR was submitted for the 6.0 branch but it was merged into the 6.1 branch instead. Discussion ---------- [DoctrineBridge] Restore PHP8 features for Doctrine debug middlewares | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | To merge #45491 in 5.4, the code has been changed to be 7.2 compliant. This PR restores the original code for Symfony versions that support php >= 8.0 (see #45491 (comment)). Commits ------- f4bdd82 Restore PHP8 features for Doctrine debug middlewares
The SqlLogger that is used in doctrine bridge and doctrine bundle has been deprecated and replaced by a system of Middleware.
A work has started on Doctrine bundle with doctrine/DoctrineBundle#1456 and doctrine/DoctrineBundle#1472
This PR suggest to add a middleware thats covers what was previously done by
DbalLogger
andDebugStack
.Another PR will follow in DoctrineBundle for the integration.