Opened 13 years ago
Closed 13 years ago
#16812 closed defect (bug) (wontfix)
Taxonomy queries without joins ignore order by
Reported by: | Chad Killingsworth | Owned by: | scribu |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description
Using a category exclusion term on a query causes the posts to be ordered ascending. Example
I was able to work around the problem by not including a GROUP BY clause when $join variable is empty. I've attached the patch but I'm not sure this is the best solution.
Attachments (1)
Change History (17)
#1
@
13 years ago
- Owner set to scribu
- Status changed from new to reviewing
(yes, I'm actually reviewing this time)
#2
@
13 years ago
Thanks for reporting and scribu thanks a lot for your support, please fix if you can for 3.1.1.
#4
@
13 years ago
- Keywords reporter-feedback added
$groupby doesn't affect $orderby in any way, so this is really strange.
Please add the following lines of code somewhere after The Loop and paste here what you get when you go to ?cat=-1
echo '<pre>'; print_r($wp_query->query_vars); print_r($wp_query->request);
#6
@
13 years ago
- Cc chadkilllingsworth@… added
I have a test instance setup and I disabled all plugins before I began testing/debugging the issue. I agree with your statement about the strangeness of the group by/order by conflict. The SQL Statement including the group by clause looks perfectly valid to me and I don't understand why it would affect post ordering in any way.
Here's the query variables and request output:
Array ( [cat] => -1 [feed] => atom [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [tag_id] => [author_name] => [tb] => [paged] => 0 [comments_popup] => [meta_key] => [meta_value] => [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( [0] => 1 ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [meta_query] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [post_type] => [posts_per_page] => 10 [nopaging] => [comments_per_page] => 50 [no_found_rows] => [order] => DESC [orderby] => wp_1_posts.post_date DESC ) SELECT SQL_CALC_FOUND_ROWS wp_1_posts.* FROM wp_1_posts WHERE 1=1 AND ( wp_1_posts.ID NOT IN ( SELECT object_id FROM wp_1_term_relationships WHERE term_taxonomy_id IN (1) ) ) AND wp_1_posts.post_type = 'post' AND (wp_1_posts.post_status = 'publish' OR wp_1_posts.post_status = 'private') GROUP BY wp_1_posts.ID ORDER BY wp_1_posts.post_date DESC LIMIT 0, 10
#7
@
13 years ago
It works ok for me.
Try running that query directly through phpMyAdmin and see if it still happens.
#8
@
13 years ago
On my SQL Server, the results returned in reverse order (i.e. the problem still occurs). I'm running 5.0.51b-community-nt on a 64bit windows server.
#9
@
13 years ago
It looks like it may be this MySql bug: http://bugs.mysql.com/bug.php?id=32202
I can simply upgrade our MySql server, but since this is a supported version for Word Press, you may want to still work around the issue.
#15
@
13 years ago
Unless we have a simple workaround, this might be wontfix since it is apparently due to a bug in a particular version of MySQL.
#16
@
13 years ago
- Keywords has-patch removed
- Milestone 3.2 deleted
- Resolution set to wontfix
- Status changed from reviewing to closed
I've tried some variations on the current patch, but it didn't help.
I think those affected will just have to wait for the next minor release of MySQL or upragrade to MySQL 5.1.
Query.php patch for group by/order by conflict