johnbillion / query-monitor

The developer tools panel for WordPress
https://querymonitor.com
GNU General Public License v2.0
1.6k stars 211 forks source link

Check QM_VERSION Constant Before Defining #751

Closed michael-sumner closed 1 year ago

michael-sumner commented 1 year ago

On WordPress VIP platform, the query-monitor plugin is part of the VIP Go mu-plugins. Therefore, it will throw an error if the query-monitor plugin is also installed and activated in the /plugins directory.

This PR fixes the issue by defining the constant only if it is not yet defined.

Screenshot 2023-03-21 at 14 11 38

michael-sumner commented 1 year ago

I have checked all other constant define blocks across the repo, and they are all ok

johnbillion commented 1 year ago

Thanks for the PR. I'm very hesitant to make this change because it's papering over the underlying issue which is that two versions of the same plugin are active. If that's the case then most of the functionality in the plugin will be happening twice, and with the class autoloading you may be loading different versions of class definitions to what are expected.

I think the solution here is to fix the underlying problem which is that you have a plugin active that's also a mu-plugin, and that's never a good idea.

Cheers!