#60228 closed defect (bug) (invalid)
has_published_pages method does not always return intended result
Reported by: | sconroy | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 6.0 |
Component: | Customize | Keywords: | |
Focuses: | Cc: |
Description
The has_published_pages method in class-wp-customizer-manager.php has the potential to return an inaccurate result. It only checks the retrieval of a single page. Thus if there are any 'get_pages' filters utilized to remove that first page from the return, then the has_published_pages method returns false when there are other published pages. Even if there are tens of pages published the function will still return false if that first page is filtered out of the get_pages call.
This potentially inaccurate return can cause the Homepage Settings sub-menu to disappear from the Appearance->Customize menu.
A more accurate measure of if the user has published pages would not rely on a single page.
Change History (4)
#2
follow-up:
↓ 3
@
12 months ago
- Keywords reporter-feedback added
- Version set to 6.0
Hi @sconroy, and welcome to WordPress Trac! Thanks for the report.
What's an example use case of a get_pages
filter that removes the found page?
The current logic was introduced in #55425, and the reasoning behind it still stands, I think. Using wp_count_posts()
is an interesting idea, although that, too, is filterable.
#3
in reply to:
↑ 2
@
6 months ago
- Keywords reporter-feedback removed
- Resolution set to maybelater
- Status changed from new to closed
Replying to dlh:
Hi @sconroy, and welcome to WordPress Trac! Thanks for the report.
What's an example use case of a
get_pages
filter that removes the found page?
The current logic was introduced in #55425, and the reasoning behind it still stands, I think. Using
wp_count_posts()
is an interesting idea, although that, too, is filterable.
Hello @dlh, thank you for the timely response and apologies for the late reply.
After some much-needed refactoring of the legacy code that filtered out the found page, this is no longer an issue for the code base I am working on. I have marked this ticket as resolved.
While I could imagine a corner of the universe in which someone might want to filter out a page and end up coming across the same issue I did, I cannot put that imaginary use case into words and thus cannot advocate for this fix even if I wanted to.
"wp_count_posts('page')->publish" seems like a better way of retrieving a count of the site's published pages.