[wp-trac] [WordPress Trac] #47552: post_name when inserting is not guaranteed to be unique
WordPress Trac
noreply at wordpress.org
Tue Jun 18 00:41:05 UTC 2019
#47552: post_name when inserting is not guaranteed to be unique
--------------------------+-----------------------------
Reporter: domslee | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Hi all,
In wp_insert_post, there is a gap between the allocation of the post_name
(as wp_unique_post_slug), and the insertion ($wpdb->insert) of the post.
This is problematic because another WordPress instance can insert a post
with the same post_name in this gap, which would result in two posts being
inserted with the same post name
See here for an example:
https://github.com/domsleee/wp_insert_post_duplicate
I suppose a solution may be to obtain a table lock, then find a unique
slug and insert the post, and then release the table lock... but this
doesn't seem very performant. What do you guys think?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47552>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list