Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fatal when other plugins use old-style constructors #7

Closed
simonwheatley opened this Issue · 13 comments

3 participants

@simonwheatley
Collaborator

If a plugin uses the old-style constructor then Query Monitor fails with a PHP fatal error on WPEngine:

Fatal error: Class 'QM_Util' not found in /nas/wp/www/staging/pencil/wp-content/plugins/co-authors-plus/co-authors-plus.php on line 112

If the old style constructor method is commented out, leaving the proper __construct, then the fatal goes away.

@simonwheatley
Collaborator

I cannot work out what in QM is getting run on these constructors so I can determine a fix. Do you know what might be getting triggered on an old-style constructor?

@simonwheatley
Collaborator

I've tracked it down to the QM_Component_PHP_Errors class calling QM_Util::backtrace() before it's available. Requiring the file if the method isn't callable does not seem to help. Quick fix was to change the method as follows:

diff --git a/wp-content/plugins/query-monitor/components/php_errors.php b/wp-content/plugins/query-monitor/components/php_errors.php
index 3a95363..0f84c48 100755
--- a/wp-content/plugins/query-monitor/components/php_errors.php
+++ b/wp-content/plugins/query-monitor/components/php_errors.php
@@ -173,6 +173,19 @@ class QM_Component_PHP_Errors extends QM_Component {

        if ( error_reporting() > 0 ) {

+           if ( ! is_callable( 'QM_Util::backtrace' ) ) {
+               $this->data['errors'][$type][$key] = (object) array(
+                   'errno'    => $errno,
+                   'type'     => $type,
+                   'message'  => $message,
+                   'file'     => $file,
+                   'filename' => 'unknown',
+                   'line'     => $line,
+                   'funcs'    => 'unknown',
+                   'calls'    => 1
+               );
+               return;
+           }
            $funcs = QM_Util::backtrace();

            if ( !isset( $funcs[0] ) )
@johnbillion
Owner

Can you try updating to the latest QM code from the GitHub repo? It should fix that issue.

@simonwheatley
Collaborator

Updating didn't seem to fix it. QM on WPE is v2.4.1.

@simonwheatley
Collaborator

(Double checking that.)

@johnbillion
Owner

Ah ok, I just looked in the cftp/ir-2013 repo and saw QM was still on a 2.4 beta.

@simonwheatley
Collaborator

I hadn't pushed the IR changes to GitHub. Here they are now:

Anyway, this is getting dangerously close to you doing Work™. I'm going to shut up now.

@johnbillion
Owner

screen shot 2013-08-09 at 14 55 44

^ Internet Retailing site on WPE.

/me gone.

@simonwheatley
Collaborator

whispers I'm testing on staging. ;)

/me was never here

@johnbillion johnbillion was assigned
@scottsweb

Seeing this issue too when activating plugins on Pearson (WPE again).

Fatal error: Class 'QM_Util' not found in /nas/wp/www/cluster-1678/pearson/wp-content/plugins/video-library/Plugin.php on line 78

I am running 2.4.1 of QM and this is against our own Video Library plugin.

@simonwheatley
Collaborator

@scottsweb – If you patch QM with this cftp/st-jpp@cabad94 does it work for you?

@johnbillion
Owner

I think this is a combination of the way strict errors are reported on WPE and the fact that WPE doesn't allow the wp-content/db.php symlink to be put into place. I'll take a look at my next available opportunity :)

@scottsweb

Before even applying the patch @simonwheatley I decided to deactivate and reactivate the plugin... and it worked. So without the patch a second activation seems fine.

I have now applied the patch and will see if it appears again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.