In J4.0 (I have not checked previous versions),
the debug monitor does not display any queries made prior to the initialisation of the system debug plugin.
I discovered it when I am working with Access class, for ex. a query with #__viewlevels
table is not visible in debug bar.
May be DebugMonitor
should be initialised earlier, by JDEBUG constant, instead of the debug plugin.
Labels |
Added:
?
|
Status | New | ⇒ | Discussion |
Labels |
Added:
J4 Issue
|
Is this still an issue with the new debugger?
Yes.
I have prepared a dirty patch on J4:
diff --git a/libraries/src/Service/Provider/Database.php b/libraries/src/Service/Provider/Database.php
index 86d50fc875..ac823b0df6 100644
--- a/libraries/src/Service/Provider/Database.php
+++ b/libraries/src/Service/Provider/Database.php
@@ -90,6 +90,12 @@ class Database implements ServiceProviderInterface
'prefix' => $conf->get('dbprefix'),
];
+ if (defined('JDEBUG') && JDEBUG)
+ {
+ require JPATH_ROOT . '/plugins/system/debug/DebugMonitor.php';
+ $options['monitor'] = new \Joomla\Plugin\System\Debug\DebugMonitor(true);
+ }
+
try
{
$db = DatabaseDriver::getInstance($options);
diff --git a/plugins/system/debug/debug.php b/plugins/system/debug/debug.php
index 17a448c438..357caea558 100644
--- a/plugins/system/debug/debug.php
+++ b/plugins/system/debug/debug.php
@@ -166,10 +166,15 @@ class PlgSystemDebug extends CMSPlugin
// @todo Remove when a standard autoloader is available.
JLoader::registerNamespace('Joomla\\Plugin\\System\\Debug', __DIR__, false, false, 'psr4');
- // Attach our query monitor to the database driver
- $this->queryMonitor = new DebugMonitor(JDEBUG);
+ $this->queryMonitor = $this->db->getMonitor();
- $this->db->setMonitor($this->queryMonitor);
+ if (!($this->queryMonitor instanceof DebugMonitor))
+ {
+ // Attach our query monitor to the database driver
+ $this->queryMonitor = new DebugMonitor(JDEBUG);
+
+ $this->db->setMonitor($this->queryMonitor);
+ }
$storagePath = JPATH_CACHE . '/plg_system_debug_' . $this->app->getClientId();
and on database framework:
diff --git a/src/DatabaseDriver.php b/src/DatabaseDriver.php
index b6aeed5..2c560ed 100644
--- a/src/DatabaseDriver.php
+++ b/src/DatabaseDriver.php
@@ -1697,6 +1697,18 @@ abstract class DatabaseDriver implements DatabaseInterface, DispatcherAwareInter
return $literal;
}
+ /**
+ * Get a query monitor.
+ *
+ * @return QueryMonitorInterface|null
+ *
+ * @since __DEPLOY_VERSION__
+ */
+ public function getMonitor()
+ {
+ return $this->monitor;
+ }
+
/**
* Set a query monitor.
*
The conclusion is that DebugMonitor
should be moved to the Joomla Database structure.
And a screen shot of what we are currently losing (backend):
I have done the first PR joomla-framework/database#147 to move it forward.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-12-28 21:56:46 |
Closed_By | ⇒ | csthomas |
Yes and no. The debug functionality in core shouldn't be coupled to a plugin and I really wish someone would extract its logic into the core API. But, as long as it is in a plugin, core shouldn't be putting resources from that plugin into parts of the code that run outside the plugin (i.e. to do it right the query monitor would have to be loaded in the database service provider and the monitor be made a part of the libraries API instead of a plugin class).