Opened 13 years ago
Closed 13 years ago
#17264 closed defect (bug) (fixed)
Duplicate posts returned if multiple meta_values match and no meta_key is set
Reported by: | trepmal | Owned by: | dd32 |
---|---|---|---|
Milestone: | 3.1.3 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | Query | Keywords: | has-patch fixed-major |
Focuses: | Cc: |
Description
I'm currently experiencing issues that appear to be related to the second point of 12660, "Using just meta_value returns duplicate posts based on the meta_value"
I have a post with multiple custom fields, for example
"address" with value "123 Lorem St"
"city" with value "Lorem"
When I perform a search to return posts with any meta_value LIKE 'sequim' ...
$args = array( 'meta_query' => array( array( 'value' => 'lorem', 'compare' => 'LIKE' ) ) ); query_posts($args);
... the post I described above is returned twice, once for each meta_value that matches.
I'd expect WP to handle the result in a way that duplicate posts would not be returned.
My current workaround is to require the user to choose a key to search in, but I'd like to be able to do more of an all-in-one search.
Attachments (5)
Change History (25)
#2
@
13 years ago
- Keywords reporter-feedback removed
Point-release nightlies gets me 3.1.2-alpha
problem persists
Bleeding edge nightlies gets me 3.2-bleeding
produces the following error (and no search results):
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10' at line 1]
SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND ( ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
#5
@
13 years ago
I was running 3.2-bleeding when I got the WordPress database error mentioned above.
I just double-checked my version number against what I got from http://core.svn.wordpress.org/trunk/
#6
@
13 years ago
Ah sorry, I didn't see your full comment. All I saw was "Point-release nightlies". Thanks.
#8
@
13 years ago
- Keywords has-patch added
Forgot to mention, this is the invalid sql
AND ( ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
#9
@
13 years ago
17264.3.diff: handle empty and invalid meta queries.
unit-meta-query.php: more unit tests; also check JOIN clause.
#13
@
13 years ago
17264.4.diff fixes duplicate posts for 3.1 branch.
#14
follow-up:
↓ 15
@
13 years ago
Please only add the fixed-major keyword if you can also change the milestone. Otherwise it will get stuck in limbo.
Is this a regression in 3.1 from 3.0?
#15
in reply to:
↑ 14
@
13 years ago
Replying to nacin:
Please only add the fixed-major keyword if you can also change the milestone. Otherwise it will get stuck in limbo.
Ok got it
Is this a regression in 3.1 from 3.0?
Yes
#17
follow-up:
↓ 18
@
13 years ago
- Keywords fixed-major added
- Milestone changed from 3.2 to 3.1.3
greuben deserved some percentage of props as well. :)
oops, Sorry Gruben, That's what testing for too long and committing it because you can no longer handle looking at code does to you.
I'll take a look at the 3.1 branch today
#18
in reply to:
↑ 17
@
13 years ago
Replying to dd32:
greuben deserved some percentage of props as well. :)
oops, Sorry Gruben, That's what testing for too long and committing it because you can no longer handle looking at code does to you.
I understand its okay. BTW its Greuben
Please test this with the latest nightly build. You can use the Beta Tester plugin.