J4 Issue ? ?
avatar csthomas
csthomas
9 Apr 2018

Steps to reproduce the issue

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.

avatar csthomas csthomas - open - 9 Apr 2018
avatar joomla-cms-bot joomla-cms-bot - labeled - 9 Apr 2018
avatar joomla-cms-bot joomla-cms-bot - change - 9 Apr 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 9 Apr 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 9 Apr 2018
Status New Discussion
avatar mbabker
mbabker - comment - 9 Apr 2018

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).

avatar brianteeman brianteeman - change - 13 May 2018
Labels Added: J4 Issue
avatar brianteeman brianteeman - labeled - 13 May 2018
avatar brianteeman
brianteeman - comment - 14 Oct 2018

Is this still an issue with the new debugger?

avatar mbabker
mbabker - comment - 14 Oct 2018

Yes.

avatar csthomas
csthomas - comment - 13 Nov 2018

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):
screenshot_20181113_104800

avatar csthomas
csthomas - comment - 19 Dec 2018

I have done the first PR joomla-framework/database#147 to move it forward.

avatar csthomas
csthomas - comment - 28 Dec 2018

Please test #23375

avatar csthomas csthomas - close - 28 Dec 2018
avatar csthomas csthomas - change - 28 Dec 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-12-28 21:56:46
Closed_By csthomas

Add a Comment

Login with GitHub to post a comment