Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#16730 closed defect (bug) (fixed)

query_posts() problem with multiple tags since 3.1 update

Reported by: joshstauffer's profile joshstauffer Owned by: scribu's profile scribu
Milestone: 3.1.1 Priority: normal
Severity: normal Version: 3.1
Component: General Keywords:
Focuses: Cc:

Description (last modified by scribu)

When I upgraded to 3.1 this query stopped working.

Does NOT return any results in 3.1:

query_posts( 'cat=8&tag=featured+hotels-and-motels' );

Returns expected results in 3.1:

$args = array (
	'cat' => 8,
	'tag_slug__and' => 'featured+hotels-and-motels',
);
query_posts( $args );

Another user with similar experience.

Attachments (2)

16730.quick-n-dirty.diff (471 bytes) - added by scribu 14 years ago.
16730.diff (871 bytes) - added by ryan 14 years ago.
array_unique() for tag_slug_*. Untested.

Download all attachments as: .zip

Change History (20)

#1 @nacin
14 years ago

  • Milestone changed from Awaiting Review to 3.1.1

3.1.1 for investigation.

#2 @scribu
14 years ago

  • Owner set to scribu
  • Status changed from new to accepted

#3 @scribu
14 years ago

  • Description modified (diff)

#4 @scribu
14 years ago

Caused by [17272], which added back the old processing, but didn't skip the new, global, processing.

#5 @scribu
14 years ago

Also, since [17489], the terms are doubled.

#6 @ryan
14 years ago

I don't know if we can do it at this point, but having all taxonomies support '+' and ',' might be nice.

#7 @scribu
14 years ago

Re doubling:

The trouble is that after each call to parse_query(), 'tag_slug__and' and 'tag_slug__in' are populated again, without being reset.

Two ways of going about this:

  • Reset them using $wp_query->query. This is the easiest way, but is a potential source of future bugs.
  • Don't manipulate them at all; parse 'cat' and 'tag' directly into tax_query.
Last edited 14 years ago by scribu (previous) (diff)

#8 @scribu
14 years ago

Actually, the first approach will cause bugs: say, if someone were to set 'category__and' on 'pre_get_posts', so nevermind that.

Last edited 14 years ago by scribu (previous) (diff)

#9 @ajsadeh
14 years ago

  • Cc amir@… added

As per IRC convo confirming that the issue I reference here and in Support Forum is a related issue with failure of 'category__and' since 3.1 update.

Last edited 14 years ago by scribu (previous) (diff)

@ryan
14 years ago

array_unique() for tag_slug_*. Untested.

#10 @ryan
14 years ago

Can we not do array_unique() on those like we do everywhere else?

#11 @scribu
14 years ago

I guess that will have to do.

#12 @scribu
14 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

So, for 'category', include_children is false. That's expected, since 'cat' is lame.

But, for 'post_tag', include_children is set to true. That shouldn't be.

#13 @scribu
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#14 @scribu
14 years ago

Nevermind that last comment; include_children is ignored unless the taxonomy is hierarchical.

#15 @ajsadeh
14 years ago

I resolved my issue by changing the query to use an Advanced Taxonomy Query. Details are on the support forum.

#16 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [17500]) Don't double process the tag query var. Props scribu. fixes #16730 for trunk

#17 @ryan
14 years ago

(In [17501]) Don't double process the tag query var. Props scribu. fixes #16730 for 3.1

#18 @scribu
14 years ago

Could we also get 16730.diff in?

Note: See TracTickets for help on using tickets.