Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#6595 closed defect (bug) (fixed)

Editing permalink allows duplicate permalinks

Reported by: synapsestudios Owned by: nbachiyski
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.5
Component: Administration Keywords: has-patch
Focuses: Cc:


I create and publish a post in uncategorized named Test, the permalink is:

I then create and publish an identical post, the permalink is:

So far, so good.

When I go to edit the second post, and try to edit the permalink such that the slug is simply "test", it allows me to Save that without providing any warning. It also shows the permalink as http://www.example.com/uncategorized/test/

Expected Result: When saving the duplicate slug, I would want it to notify me that it was unable to do so and then display the original permalink/slug.

Another scenario that relates to the functionality of the edit permalink's Save button is as follows:
Using the same scenario as above, but this time instead of changing test-2 to "test" I change it to "test-3" (a unique slug). I hit the Save button that is next to the Permalink and then leave the page. The changes, however, are not really saved at this point.

Expected Result: If it isn't actually saving anything, it shouldn't say "Save" or it should at least warn me that leaving the page would lose my changes.

I think if the Save button for the Permalink made an AJAX call, it could solve both of these problems. It could check if the slug was a duplicate and save it and the post right away if it was, otherwise it could trigger a notice to the user.

Attachments (1)

no-duplicate-permalinks-on-edit.diff (4.1 KB) - added by nbachiyski 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 nbachiyski6 years ago

  • Owner changed from anonymous to nbachiyski

comment:2 pishmishy6 years ago

  • Summary changed from Editing permalink/post slug does not provide expected results to Editing permalink allows duplicate permalinks

I'm splitting this ticket into two issues. Permalinks not being saved can be dealt with at #6925.

comment:3 ryan6 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

comment:4 nbachiyski5 years ago

  • Keywords has-patch added
  • Milestone changed from 2.9 to 2.8

Here is a patch, which abstracts the logic of adding suffixes on duplicate slugs into wp_unique_slug(). Then the functions is used both on post saving and on generating sample permalinks.

comment:5 ryan5 years ago

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

(In [11071]) Add wp_unique_post_slug(). Apply it when getting sample permalinks. Props nbachiyski. fixes #6595

Note: See TracTickets for help on using tickets.