Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#15487 closed defect (bug) (fixed)

Custom permalinks redirecting back to category list instead of post

Reported by: tott's profile tott Owned by: garyc40's profile garyc40
Milestone: 3.1 Priority: high
Severity: blocker Version: 3.1
Component: Canonical Keywords:
Focuses: Cc:

Description

Using a custom permalink structure such as

/%category%/%post_id%/%postname%/

hitting a post permalink will redirect you back to the category although debugging via a filter attached to parse_request shows the correct query (matched_query).


Attachments (3)

15487.singular.diff (882 bytes) - added by markjaquith 14 years ago.
Do not set is_(category|tag|tax) for is_singular
15487.diff (1010 bytes) - added by greuben 14 years ago.
15487-2.diff (1.8 KB) - added by greuben 14 years ago.
need some more testing

Download all attachments as: .zip

Change History (29)

#1 @nacin
14 years ago

  • Component changed from Rewrite Rules to Canonical
  • Keywords needs-patch added; permalink_structure wp_rewrite rewrite removed
  • Milestone changed from Awaiting Review to 3.1

#3 @ryan
14 years ago

canonical.php is confused. I think it sees this as a tax query rather than a single post query.

#4 @mtekk
14 years ago

It is broken for all instances of %category% in your permalinks e.g. /archives/%category%/%postname% is broken as well

#5 @mtekk
14 years ago

The latest revision that it works on is [16379], it is broken by the next revision [16380]

#6 @markjaquith
14 years ago

is_category is being set, and it shouldn't be.

@markjaquith
14 years ago

Do not set is_(category|tag|tax) for is_singular

#7 @markjaquith
14 years ago

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

(In [16495]) Do not set is_category/is_tax/is_tax for is_singular requests. props mtekk. fixes #15487

#8 @mtekk
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Still broken, and is sort of worse now. Can end up in infinite redirect loops, or lead to pages instead of posts. Must be more to this, unless I have borked my testbed install somehow.

From what I can tell, if there is only one post in the category WordPress is able to find the correct page 100% of the time. If there are multiple posts in the category, it seems like the most recent post is the only one that will load reliably. This is true for all categories except the default category (Uncategorized or as I have it renamed General). The default category is broken, all of the posts that are members of it end up getting stuck in redirect loops.

#9 @markjaquith
14 years ago

  • Priority changed from normal to high
  • Severity changed from normal to blocker

My fault... had some code in mu-plugins that was messing with redirects. I see the problem exhibited fully, now. Bumping up priority/severity. Can take a look tonight, but if someone wants to take a swing in the meantime, go ahead.

is_category should be FALSE for these requests, because they're is_single requests. And the category portion of the URL is typically ignored when making the query (because you have a unique post slug or ID) — that may have changed in 3.1

#10 @scribu
14 years ago

I'm looking into this now.

#11 @ryan
14 years ago

(In [16513]) array_unique() categoryin and categorynot_in to eliminate dupes from multiple runs of parse_tax_query(). Fixes canonical redirects for cat, categoryin, and categorynot_in requests. see #12891 #15487

#12 @automattor
14 years ago

(In [16515]) Don't do any taxonomy stuff if is_singular. See #15487

#13 @mtekk
14 years ago

Looks like the last commit by automattor fixed it. Anyone else confirm?

#14 @ryan
14 years ago

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

#15 @tar.gz
14 years ago

  • Cc tar.gz added
  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm currently running 3.1-beta1-16732 and I see this issue reappearing on a site that was fine in WP 3.0.3.

My custom link structure is: /%year%/%category%/%postname%/ (since starting with %category% is not recommended for performance reasons).

#16 @tar.gz
14 years ago

Note: the previous beta build i was running was [16723], here the permalinks were still working.

Note2: a custom structure such as /%year%/%postname%/ works fine, so it's really the %category% that causes the trouble.

#17 @garyc40
14 years ago

  • Owner set to garyc40
  • Status changed from reopened to assigned

@greuben
14 years ago

#18 @greuben
14 years ago

  • Keywords has-patch added; needs-patch removed

#19 @greuben
14 years ago

  • Keywords needs-patch added; has-patch removed

The last patch works but is not returning proper results

@greuben
14 years ago

need some more testing

#20 @greuben
14 years ago

  • Keywords needs-testing added; needs-patch removed

#21 @greuben
14 years ago

  • Keywords needs-patch added; needs-testing removed

whoops...working at wrong file and lines

#22 @mtekk
14 years ago

Looks like scribu broke it in [16851]

#23 @scribu
14 years ago

(In [16880]) Don't set query flags in parse_tax_query(). See #15487

#24 @scribu
14 years ago

Should be fixed now. Please confirm.

#25 @scribu
14 years ago

  • Keywords needs-patch removed

#26 @mtekk
14 years ago

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

Ok, works for me now, again, closing as fixed

Note: See TracTickets for help on using tickets.