Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#45357 closed defect (bug) (invalid)

filter wp_unique_post_slug > doesn't pass original_slug

Reported by: preliot's profile preliot Owned by:
Milestone: Priority: normal
Severity: minor Version: 5.0
Component: Posts, Post Types Keywords:
Focuses: Cc:


I'm using WordPress 5.0 Beta 4. Also noticed bug in earlier versions, such as 4.9.8.

Steps to recreate:

  • Create new page / post
  • Save post
  • Edit post and change slug
  • Filter 'wp_unique_post_slug' passes same value for $slug and $original_slug

Expected outcome:

  • $slug = new slug
  • $original_slug = old slug

Change History (2)

#1 @swissspidy
6 years ago

  • Component changed from General to Posts, Post Types
  • Keywords needs-patch needs-testing removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi there and welcome to WordPress Trac!

The value of $original_slug isn't the old slug of the post, but the original value of the $slug at the beginning of the wp_unique_post_slug function, before it was modified.

When you edit the post in the editor, you tell WordPress your new slug. To make sure the new value is unique across posts, it's ran through wp_unique_post_slug. The old value of the slug is not involved in this process at all.

#2 @preliot
6 years ago

@swissspidy Thanks for the clarification.

Note: See TracTickets for help on using tickets.