Make WordPress Core

Opened 9 years ago

Closed 2 months ago

#39942 closed defect (bug) (worksforme)

Restored Post may steal slug to published Post

Reported by: ziodave's profile ziodave Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

Steps to reproduce:

  1. Create a Post 1 with title "Post",
  2. Assign the slug 'post' to Post 1,
  3. Publish Post 1,
  4. Unpublish Post 1 by setting it as 'Draft', then Update,
  5. After Update, Trash Post 1,
  6. Repeat 1-5 for Post 2,
  7. Create a Post 3 with title "Post",
  8. Assign the slug 'post' to Post 3,
  9. Publish Post 3,
  10. Now restore Post 2,
  11. Open/Reload the edit screen for Post 3,
  12. It'll show 'post-2' as slug,
  13. Saving/Updating Post 3 will change the slug from 'post' to 'post-2'.

Probably the following functions participate in the issue:

  • wp_add_trashed_suffix_to_post_name_for_post, which is checking for
if ( '__trashed' === substr( $post->post_name, -9 ) ) {

while Post 2 has post__trashed-2 as post name

  • wp_unique_post_slug, which is not checking the uniqueness of the slug if the post is draft.

Change History (3)

This ticket was mentioned in Slack in #core by ziodave. View the logs.


9 years ago

#2 @SirLouen
7 months ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to Future Release
  • Version 4.7.2 deleted

Related #61996 #47552
I'm not sure if this (or the other) are duplicates #61996. Look very similar, need reproduction

#3 @r1k0
2 months ago

  • Keywords needs-testing removed
  • Resolution set to worksforme
  • Status changed from new to closed

Reproduction Report

Environment

  • WordPress: 6.9
  • PHP: 8.4.17
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 144.0.0.0
  • OS: Linux
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Steps taken

  1. Create a post and name it "Post", and publish it.
  2. On the post edit page, change the post status from published to draft, and click update.
  3. Trash this post.
  4. Repeat steps 1 - 3.
  5. Create a third post and publish it.
  6. Restore the second post you created, change its status from draft to published, and update changes.
  7. Click the quick edit button on the post just restored, observe the slug input field.
  8. Click the quick edit button on the third post you created, observe the slug input field.
  9. ❌ Bug is not occurring

Expected behavior

  • The third post still retains its slug, and the restored post gets another slug i.e., "post-2".

Additional Notes

  • This issue seems to have been solved.

Screenshots/Screencast with results

Note: See TracTickets for help on using tickets.