[wp-trac] [WordPress Trac] #52422: Create a draft with the same slug as an existing post, the existing post will be 404.
WordPress Trac
noreply at wordpress.org
Thu May 26 20:24:30 UTC 2022
#52422: Create a draft with the same slug as an existing post, the existing post
will be 404.
-------------------------------------------------+-------------------------
Reporter: Toro_Unit | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.1
Component: Posts, Post Types | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has- | Focuses:
testing-info early dev-feedback |
-------------------------------------------------+-------------------------
Comment (by costdev):
Following up on [https://core.trac.wordpress.org/ticket/52422#comment:16
comment 16], `$prepared_post->post_type = $this->post_type;` doesn't
appear to have any effect.
I added the line back in along with some logging before and after it.
Results below.
{{{
Before: wp_block | After: wp_block
Before: wp_block | After: wp_block
Before: page | After: page
Before: page | After: page
Before: post | After: post
Before: post | After: post
Before: post | After: post
// ...continues with `post | post` for a while.
}}}
-----
I believe this is because
`WP_REST_Posts_Controller::prepare_item_for_database()` sets the post type
[https://github.com/WordPress/wordpress-
develop/blob/15deb80e504a6ede868bedc1e64e448536d88771/src/wp-includes
/rest-api/endpoints/class-wp-rest-posts-controller.php#L1179 at this
location].
Whether this line is redundant is a matter for another ticket, and
@rachelbaker might be able to give some insight on this.
Until then, I'll add the line back in and submit a PR to show CI passing.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52422#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list