[buddypress-trac] [BuddyPress Trac] #9086: Filter on `wp_unique_post_slug` issue
buddypress-trac
noreply at wordpress.org
Fri Feb 2 16:43:53 UTC 2024
#9086: Filter on `wp_unique_post_slug` issue
--------------------------+-----------------------------
Reporter: ahegyes | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Core | Version: 12.2.0
Severity: normal | Keywords:
--------------------------+-----------------------------
Hello!
Version 12.0.0 introduced a new filter function called
`bp_core_set_unique_directory_page_slug` attached to the filter
`wp_unique_post_slug`.
My understanding is that the function wants to avoid any duplicate
`post_name` entries across the post types `buddypress` and `page`.
However, it seems to fail in doing that and causes issues in certain
cases.
For example, it tries to accomplish its goal by first querying a list of
posts of type `buddypress` and `page`
([https://github.com/buddypress/buddypress/blob/b5f1c43598581173edb3cbd2686ae075f912ae87/src
/bp-core/bp-core-functions.php#L1002-L1008]). However, since it doesn't
use the `limit` or `numberposts` argument, only the top 5 posts will be
returned instead of all of them.
Moreover, it doesn't handle hiearchies properly. Normally, pages are
allowed to have the same `post_name` as long as they have different
parents. However, this function doesn't take that into account.
In my scenario, I tried adding a page named `Program` as child of page
`B`. However, this function's `get_posts` included another page named
`Program` which is a child of page `A`. WordPress allows this, but this
function changed the slug to `program-2` for the child of `B` because the
child of `A` happened to be amongst those 5 queried posts.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9086>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list