[wp-trac] [WordPress Trac] #51427: wp_publish_post function does not check for unique postname in database
WordPress Trac
noreply at wordpress.org
Thu Oct 1 06:01:25 UTC 2020
#51427: wp_publish_post function does not check for unique postname in database
-------------------------------+-----------------------------
Reporter: mihirgosai | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 5.5.1
Severity: major | Keywords: dev-feedback
Focuses: administration |
-------------------------------+-----------------------------
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 ) );
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51427>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list