[wp-trac] [WordPress Trac] #50447: wp_publish_post not checking for unique post slugs
WordPress Trac
noreply at wordpress.org
Mon Jun 22 16:59:10 UTC 2020
#50447: wp_publish_post not checking for unique post slugs
---------------------------+-----------------------------
Reporter: hughie.molloy | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Canonical | Version: trunk
Severity: major | Keywords: has-patch
Focuses: |
---------------------------+-----------------------------
When published a post using wp_publish_post no check is done to see if the
slug / post_name is unique. This leads to problems with the permalink.
I have attached a patch file to the ticket as I could not make a PR to the
github
**Steps to reproduce**:
Make and publish an article titled 'test'. ID 1
Make and set to draft a second article titled ' test'. ID 2
call wp_publish_post(2)
the post name of articles 1 and 2 are both set to test.
This can be worked around by calling the following code instead:
{{{#!php
<?php
$post = [
'ID' => 2,
'post_status' => 'publish',
];
wp_update_post($post);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50447>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list