[wp-trac] [WordPress Trac] #40588: Trashing and restoring a draft post replaces the slug

WordPress Trac noreply at wordpress.org
Thu Apr 27 23:54:01 UTC 2017


#40588: Trashing and restoring a draft post replaces the slug
-------------------------------+------------------------------
 Reporter:  TJNowell           |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  4.7.4
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by Karimeo):

 I was able to recreate the issue. It seems to happen with drafts that were
 never published before. I think that it might come from the fact that when
 the post is trashed the actual slug is saved in a meta
 '_wp_desired_post_slug' so it gets restored after. However if the post was
 never published, the slug isn't set and an empty string is saved in
 '_wp_desired_post_slug'. Then when restoring, we have the following:
 {{{#!php
 if ( 'trash' === $previous_status && 'trash' !== $post_status ) {
         $desired_post_slug = get_post_meta( $post_ID,
 '_wp_desired_post_slug', true );
         if ( $desired_post_slug ) {
                 delete_post_meta( $post_ID, '_wp_desired_post_slug' );
                 $post_name = $desired_post_slug;
         }
 }

 }}}
 With an empty string being saved in '_wp_desired_post_slug' the condition
 never evaluates to true and restores the slug.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40588#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list