Opened 22 months ago
Closed 20 months ago
#9086 closed defect (bug) (fixed)
Filter on `wp_unique_post_slug` issue
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 12.4.0 | Priority: | normal |
| Severity: | normal | Version: | 12.0.0 |
| Component: | Core | Keywords: | has-patch has-unit-tests commit |
| Cc: |
Description
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.
Change History (9)
#1
@
22 months ago
- Milestone changed from Awaiting Review to 12.3.0
- Version changed from 12.2.0 to 12.0.0
This ticket was mentioned in PR #256 on buddypress/buddypress by imath.
20 months ago
#3
- Keywords has-patch has-unit-tests added
This PR also improves how Slug check is performed only requesting for pages / BuddyPress directories potentially having the same post_name and not being a child of another item.
Trac ticket: https://buddypress.trac.wordpress.org/ticket/9086
#4
@
20 months ago
Hi @ahegyes
I believe the above PR is fixing the issue, can you confirm?
Thanks in advance.
This ticket was mentioned in Slack in #buddypress by emaralive. View the logs.
20 months ago
#6
@
20 months ago
@imath, tested under the following conditions:
Without PR #256:
- Created page A, slug = a
- Created page Program as child of page A, slug = program
- Created page B, slug = b
- Created page Program as child of page B, slug = program-2
With PR #256:
- Created page A, slug = a
- Created page Program as child of page A, slug = program
- Created page B, slug = b
- Created page Program as child of page B, slug = program
Conclusion:
PR #256 provides a remedy for the reported issue.
Thanks for your report. I'll look at it asap.