Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#60228 new defect (bug)

has_published_pages method does not always return intended result

Reported by: sconroy's profile sconroy Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 6.0
Component: Customize Keywords: reporter-feedback
Focuses: Cc:


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 (2)

#1 @sconroy
3 months ago

"wp_count_posts('page')->publish" seems like a better way of retrieving a count of the site's published pages.

#2 @dlh
3 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.

Note: See TracTickets for help on using tickets.