Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#15140 closed enhancement (fixed)

When non-hierarchical CPT permalinks change, we should 301 redirect like with posts

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

Description


Change History (21)

#1 @scribu
14 years ago

I've been trying to find the code that does that, but I guess I haven't been trying hard enough.

+1 from me.

#2 @scribu
14 years ago

  • Component changed from General to Canonical

#3 @nacin
14 years ago

  • Milestone changed from Awaiting Review to 3.1
  • Owner set to nacin
  • Status changed from new to accepted

I've been meaning to create this ticket for about two weeks.

#4 @Denis-de-Bernardy
14 years ago

  • Milestone 3.1 deleted
  • Resolution set to duplicate
  • Status changed from accepted to closed

#5 follow-up: @nacin
14 years ago

  • Milestone set to 3.1
  • Resolution duplicate deleted
  • Status changed from closed to reopened

The scope for this ticket is much narrower.

I will post a patch.

#6 in reply to: ↑ 5 @Denis-de-Bernardy
14 years ago

Replying to nacin:

The scope for this ticket is much narrower.

I beg to differ. If you implement it for the previous URL without bugs (I.e. deleting conflicts as they appear), implementing it for all URLs is a matter of using multiple key/values instead of a single one.

#7 @dd32
14 years ago

I've been trying to find the code that does that, but I guess I haven't been trying hard enough.

Probably be looking for wp_old_slug_redirect() ..That really should be merged with Canonical IMO..

#8 @dd32
14 years ago

(In [15831]) Save _wp_old_slug for all published post_type's, brings old-slug redirection to Posts and CPT's. See #15140

#9 @dd32
14 years ago

(In [15832]) Use $wpdb->prepare in wp_old_slug_redirect(). See #15140

#10 @dd32
14 years ago

I realised this morning, That I didn't limit the redirection to posts of the same post type as being requested..

Potential thoughts of mine:

  • Request ALL matching records, foreach ($post ) { if ( compare post type ) { redirect;break; } }
  • JOIN in SQL, seems overkill.

#11 @dd32
14 years ago

(In [15848]) Limit wp_old_slug_redirect() to redirecting to only posts of the same post_type kind. See #15140

#12 @dd32
14 years ago

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

Closing as fixed, Re-open if a bug related to this crops up in 3.1 testing, Else, open a new ticket.

#13 @Denis-de-Bernardy
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Let's implement #9825 step/bug by step/bug...

If both the slug and the parent change, the redirect doesn't work.

#14 @Denis-de-Bernardy
14 years ago

Oh, forgot to mention. You then need to create a new page, different parent, same slug, to fully appreciate why we need to store/flush the actual permalink, rather than just the slug.

#15 @nacin
14 years ago

#9825 should stay in #9825. However, handling only the slug for hierarchical post types isn't a very good idea, I agree. Per discussion in IRC, this should be limited to non-hierarchical post types only for now.

#16 @markjaquith
14 years ago

  • Owner changed from nacin to markjaquith
  • Status changed from reopened to reviewing

Denis' objection is noted. I don't think this is ready for hierarchical post types. I'm working on a patch to restrict this to non-hierarchical post types for now, and we can look at a hierarchical fix for 3.2

#17 @automattor
14 years ago

(In [16818]) Do not do slug logging/redirects for hierarchical post types. see #15140

#18 @markjaquith
14 years ago

  • Milestone changed from 3.1 to Future Release

#19 @markjaquith
14 years ago

(In [16819]) Use is_page_type_hierarchical(). props nacin. see #15140

#20 @dd32
14 years ago

  • Milestone changed from Future Release to 3.1
  • Resolution set to fixed
  • Status changed from reviewing to closed
  • Summary changed from When page permalinks change, we should 301 redirect like with posts to When non-hierarchical CPT permalinks change, we should 301 redirect like with posts

Closing as fixed in 3.1 for non-hierarchical post types, For Pages, We have #4328 still

#21 @nacin
13 years ago

http://core.trac.wordpress.org/changeset/16818/trunk/wp-includes/query.php broke a trick I've leveraged where I stuffed _wp_old_slug into the DB for a page, and then the redirect took place. Very few have likely done that, but it's technically a regression.

Note: See TracTickets for help on using tickets.