-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Use QueryMonitorInterface instead of hard-coded DebugMonitor class #45579
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
base: 5.3-dev
Are you sure you want to change the base?
Conversation
I have tested this item ✅ successfully on 1f1117f This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45579. |
I have tested this item ✅ successfully on 1f1117f This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45579. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45579. |
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45579. |
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.
Hi,
I'm sorry but looking at this pull request this change has a bigger issue.
You change the type hint from DebugMonitor to QueryMonitorInterface, which sounds theoretically ok. But if you look at the interface you will notices that only 2 methods are defined (start and stopQuery). Which are not even used in the QueryCollector. On the other hand the QueryCollector uses
- getLogs()
- getBoundParams()
- getTimings()
- getMemoryLogs()
- getCallStacks()
which all are not defined by this interface. So it would be wrong to use this interface as type hint.
Further more, debug functionality in joomla is not part of the b/c policy and not meant to be extended, which I would expect is the reason it's final.
Which limitation do you encounter, could it be solved in the core directly and would other people benefit?
I created Sentry.io integration plugin (already in JED) and need to log SQL queries via custom monitor class. If debug is enabled, we have to apply a weird workaround to replace our custom debug monitor with native debug monitor, otherwise debug plugin fails. I am happy to add missing methods to interface, it will help and won't break anything. |
Adding new methods to an interface breaks per se the classes implementing the interface ;-) |
I am afraid I was the first one who created non-core monitor :) Maybe we can at least not make the current monitor class final? |
@laoneo , @HLeithner |
Can you prepare the pr in a way how it would work then for you, so we can discus this in maintainers meeting. There should be reason why the class is final. |
@laoneo I think it's easier to just remove final class limitation, but it requires a patch in Joomla database package https://github.com/joomla-framework/database Btw it's strange that If I add plugin-specific What do you think? |
can you elaborate where you see plugin specific code in this class? I see 2 ways to go, create an Interface or remove final... I personally would go the interface way. |
This logic is out of database package, it's the logic from debug plugin itself. So, you think to: either remove final or create a new debug plugin-specific interface and use it in the plugin. Final is evil here. We can't extend Joomla code. |
Summary of Changes
Allow debug plugin to use instance of
QueryMonitorInterface
in query collector.Currently, it's hard-coded to instance of
DebugMonitor
(which is a final class for some reason). Hence, we can't use custom monitors with debug plugin enabled.Testing Instructions
Apply patch. Enable debug in global configuration and debug plugin.
Actual result BEFORE applying this Pull Request
See debug.
Expected result AFTER applying this Pull Request
See same debug, nothing is changed.
Link to documentations
Please select: