Skip to content
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

Fatal when other plugins use old-style constructors #7

Closed
simonwheatley opened this issue Aug 9, 2013 · 13 comments
Closed

Fatal when other plugins use old-style constructors #7

simonwheatley opened this issue Aug 9, 2013 · 13 comments
Assignees
Labels

Comments

@simonwheatley
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Owner

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

@simonwheatley
Copy link
Contributor Author

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

@simonwheatley
Copy link
Contributor Author

(Double checking that.)

@johnbillion
Copy link
Owner

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

@simonwheatley
Copy link
Contributor Author

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
Copy link
Owner

screen shot 2013-08-09 at 14 55 44

^ Internet Retailing site on WPE.

/me gone.

@simonwheatley
Copy link
Contributor Author

whispers I'm testing on staging. ;)

/me was never here

@ghost ghost assigned johnbillion Aug 12, 2013
@scottsweb
Copy link

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
Copy link
Contributor Author

@scottsweb – If you patch QM with this https://github.com/cftp/st-jpp/commit/cabad94e7d7b34fa00a65790a5a25d0837372155 does it work for you?

@johnbillion
Copy link
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
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants