Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#16730 closed defect (bug) (fixed)

query_posts() problem with multiple tags since 3.1 update

Reported by: joshstauffer Owned by: 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 5 years ago.
16730.diff (871 bytes) - added by ryan 5 years ago.
array_unique() for tag_slug_*. Untested.

Download all attachments as: .zip

Change History (20)

comment:1 @nacin5 years ago

  • Milestone changed from Awaiting Review to 3.1.1

3.1.1 for investigation.

comment:2 @scribu5 years ago

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

comment:3 @scribu5 years ago

  • Description modified (diff)

comment:4 @scribu5 years ago

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

comment:5 @scribu5 years ago

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

@scribu5 years ago

comment:6 @ryan5 years ago

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

comment:7 @scribu5 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 5 years ago by scribu (previous) (diff)

comment:8 @scribu5 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 5 years ago by scribu (previous) (diff)

comment:9 @ajsadeh5 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 5 years ago by scribu (previous) (diff)

@ryan5 years ago

array_unique() for tag_slug_*. Untested.

comment:10 @ryan5 years ago

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

comment:11 @scribu5 years ago

I guess that will have to do.

comment:12 @scribu5 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.

comment:13 @scribu5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:14 @scribu5 years ago

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

comment:15 @ajsadeh5 years ago

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

comment:16 @ryan5 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

comment:17 @ryan5 years ago

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

comment:18 @scribu5 years ago

Could we also get 16730.diff in?

Note: See TracTickets for help on using tickets.