[wp-trac] [WordPress Trac] #64670: WP_REST_Posts_Controller::update_item() not passing parent to wp_unique_post_slug() for draft child
WordPress Trac
noreply at wordpress.org
Tue May 26 12:02:55 UTC 2026
#64670: WP_REST_Posts_Controller::update_item() not passing parent to
wp_unique_post_slug() for draft child
-------------------------------+-------------------------------------------
Reporter: esaner | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 6.9.1
Severity: normal | Resolution:
Keywords: has-patch needs- | Focuses: ui, administration, rest-api
testing |
-------------------------------+-------------------------------------------
Comment (by ekamran):
== Test Report ==
Patch tested: https://github.com/WordPress/wordpress-develop/pull/10973
=== Environment ===
* Reported version: 6.9.1
* Tested version: 7.1-alpha-62161-src
* PHP: 8.3.31
* Environment: wordpress-develop local Docker environment
* Test method: WP-CLI automated reproduction using `rest_do_request()`
* OS: macOS
=== Reproduction ===
I was able to confirm that the reported issue is still reproducible on
current trunk.
The test setup:
* Set up a published top-level page with slug `slug`.
* Set up a published parent page with slug `parent`.
* Set up a draft child page under the parent.
* Sent a REST API update request to the draft child page with `slug=slug`,
without sending a `parent` value.
Clean trunk result:
{{{
{
"first_id": 12,
"parent_id": 13,
"child_id": 14,
"response_status": 200,
"response_slug": "slug-2",
"stored_child_slug": "slug-2",
"stored_child_parent": 13,
"child_permalink": "http://localhost:8889/?page_id=14",
"top_slug_permalink": "http://localhost:8889/slug/"
}
}}}
This confirms the bug: the draft child page remains under parent `13`, but
the REST update changes the requested slug from `slug` to `slug-2`,
because the uniqueness check behaves as if the parent were `0`.
=== Patch Result ===
After applying PR #10973 locally and running the same automated
reproduction, the draft child page keeps the requested slug `slug` while
preserving its parent:
{{{
{
"first_id": 16,
"parent_id": 17,
"child_id": 18,
"response_status": 200,
"response_slug": "slug",
"stored_child_slug": "slug",
"stored_child_parent": 17,
"child_permalink": "http://localhost:8889/?page_id=18",
"top_slug_permalink": "http://localhost:8889/slug/"
}
}}}
=== Tests ===
I also ran the related REST pages controller PHPUnit tests with the patch
applied:
{{{
npm run test:php -- --filter WP_Test_REST_Pages_Controller
OK (34 tests, 142 assertions)
}}}
=== Notes ===
The patch fixes the REST API draft child page slug behavior by falling
back to the existing post parent when the REST update request does not
include `parent`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64670#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list