wp-rocket
wp-rocket copied to clipboard
Lack of Table Alias Causes Error in Database Query
Before submitting an issue please check that you’ve completed the following steps:
- Made sure you’re on the latest version (they use 3.15.8.1)
- Used the search feature to ensure that the bug hasn’t been reported before ✅
Describe the bug User reports getting the following error after upgrading to version 3.15.8.1:
WP_Hook->apply_filters, WP_Rocket\Engine\Preload\Cron\Subscriber->process_pending_urls, WP_Rocket\Engine\Preload\Controller\PreloadUrl->process_pending_jobs, WP_Rocket\Engine\Preload\Controller\PreloadUrl->is_excluded_by_filter, apply_filters('rocket_preload_exclude'), WP_Hook->apply_filters, WP_Rocket\Engine\Preload\Subscriber->exclude_private_url, rocket_url_to_postid, WP_Query->__construct, WP_Query->query, WP_Query->get_posts
WordPress database error Column 'post_password' in where clause is ambiguous for query
They did testing of their own and reported it's due to a unquie table-alias is missing in the generated query for the mentioned column:
SELECT SQL_CALC_FOUND_ROWS
kvVc0V_posts.ID
FROM
kvVc0V_posts
LEFT JOIN kvVc0V_posts AS p2
ON
(
kvVc0V_posts.post_parent = p2.ID
)
WHERE
1 = 1 AND(0 = 1) AND kvVc0V_posts.post_type = 'product' AND(
(
(
kvVc0V_posts.post_status = 'publish' OR kvVc0V_posts.post_status = 'private'
) OR(
kvVc0V_posts.post_status = 'inherit' AND(
p2.post_status = 'publish' OR p2.post_status = 'private'
)
)
)
) AND post_password = ''
GROUP BY
kvVc0V_posts.ID
ORDER BY
kvVc0V_posts.post_date
DESC
LIMIT 0, 6
How To Reproduce User would not share login access, so not sure of exact steps to reproduce the issue.
Expected behavior The table should be aliased to prevent the error from happening.
Additional context Ticket - https://secure.helpscout.net/conversation/2500547447/473072 Environment Details - https://secure.helpscout.net/conversation/2500547447/473072#thread-7513976852
Acceptance Criteria (for WP Media team use only) Clear instructions for developers, to be added before the grooming
I'm not sure how we can change that, the query itself is generated by the WP_Query class based on the arguments we pass. Do you have an idea @wordpressfan ?
As @Tabrisrp mentioned, we are using wp_query class to handle this and we don't change the query directly. We need to know more about the installed plugins and active theme, maybe another code is changing this.
This is not something that can be implemented in the nearest future.