Opened 5 years ago
Closed 5 years ago
#51427 closed defect (bug) (duplicate)
wp_publish_post function does not check for unique postname in database
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | major | Version: | 5.5.1 |
| Component: | Posts, Post Types | Keywords: | |
| Focuses: | administration | Cc: |
Description (last modified by )
If we use wp_publish_post function to change status of post, it does not check for unique postname (slug) from database. It can end up having two or more posts with same postname (slug).
Solution is to use code as below in wp-includes/post.php:
(function name: wp_publish_post)
$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, 'publish', $post->post_type, $post->post_parent); $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish', 'post_name' => $post->post_name), array( 'ID' => $post->ID ) );
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hi there, welcome to WordPress Trac!
Thanks for the report, we're already tracking this issue in #50447.