Skip to content

'Main query' option not available if queries contain a comment #958

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

Open
lumpysimon opened this issue Feb 26, 2025 · 0 comments
Open

'Main query' option not available if queries contain a comment #958

lumpysimon opened this issue Feb 26, 2025 · 0 comments

Comments

@lumpysimon
Copy link
Collaborator

WP Engine adds a comment on to the end of all MySQL queries via a function in the wpengine-common mu-plugin installed on all sites they host, using the query filter hook:

Here's an example of the resulting SQL:

SELECT SQL_CALC_FOUND_ROWS abc123_posts.ID
FROM abc123_posts
WHERE 1=1
AND ((abc123_posts.post_type = 'post'
AND (abc123_posts.post_status = 'publish'
OR abc123_posts.post_status = 'future'
OR abc123_posts.post_status = 'draft'
OR abc123_posts.post_status = 'pending'
OR abc123_posts.post_status = 'private')))
ORDER BY abc123_posts.post_date DESC
LIMIT 0, 100 /* From [example.com/wp-admin/edit.php] in [/nas/content/live/example/wp-content/plugins/query-monitor/classes/DB.php:29] */

This means that the 'Main query' option in Query Monitor's Caller filter is not available, because the SQL is different to $wp_the_query->request, which is what QM checks each query against.

I wonder if it's possible when doing that check to ignore any comments, so the 'Main query' option will be available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants