Make WordPress Core

Opened 14 years ago

Closed 11 years ago

#17337 closed defect (bug) (duplicate)

wp_old_slug_redirect() fails with multiple post_type query

Reported by: joehoyle's profile joehoyle Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Canonical Keywords:
Focuses: Cc:

Description

If I have a query something like this:

[query_vars] => Array
        (
            [name] => panasonic-tv-review
            [post_type] => Array
                (
                    [0] => review
                    [1] => small_review
                )
        )

The new post slug is "panasonic-250-tv-review", and there is a _wp_old_slug meta key with the old slug. One would expect wp_old_slug_redirect() to kick in and do the redirect. However, wp_old_slug_redirect() will fail with a query with multiple post types, (looking at http://core.trac.wordpress.org/browser/trunk/wp-includes/query.php#L3494). This will knock the $wpdb->prepare() ass $post_type is now an array.

I can write a patch for this if I can get the go ahead.

Change History (2)

#1 follow-up: @mordauk
11 years ago

I'm not sure I'm following this. Why would a redirect need to happen on a query for multiple post types? The wp_old_slug_redirect() should only happen (I think) when a query attempts to retrieve a single item, not a list of items. Right?

#2 in reply to: ↑ 1 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Replying to mordauk:

Why would a redirect need to happen on a query for multiple post types? The wp_old_slug_redirect() should only happen (I think) when a query attempts to retrieve a single item, not a list of items.

That query retrieves a single item.

This is, however, a duplicate of #16949.

Note: See TracTickets for help on using tickets.