Loops can develop in the post_parent hierarchy
|Reported by:||mdawaffe||Owned by:||westi|
It is possible to use wp_insert_post() to create a loop in the post_parent hierarchy.
ID = 1, post_parent = 3 ID = 2, post_parent = 1 ID = 3, post_parent = 2
The admin UI does not present this opportunity, but loops can happen elsewhere (e.g. imports, xmlrpc, etc.).
wp_insert_post() only protects against loops with node length 1 or 2 (a post's post_parent is set to its own ID, or a two posts are parents of one another). Longer loops are not caught.
Attached uses a while loop to find and break any hierarchy loop.
Change History (9)
- Keywords close added; has-patch needs-testing removed
- Milestone changed from Awaiting Triage to Awaiting Review