Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#57198 closed defect (bug) (fixed)

WP_Customize_Manager::has_published_pages() fails when queried page is not top-level

Reported by: felipelavinz's profile felipelavinz Owned by: audrasjb's profile audrasjb
Milestone: 6.2 Priority: normal
Severity: normal Version: 6.0
Component: Customize Keywords: has-patch has-testing-info commit
Focuses: Cc:

Description

The Homepage Settings section on the customizer uses WP_Customize_Manager::has_published_pages() as active_callback.

Unfortunately, the changes introduced for bug #55425 lead to an error with the logical check, which is that when the queried page it's not top-level (post_parent = 0), get_pages() incorrectly returns an empty array.

This could be solved by adding 'hierarchical' => 0 to the get_pages() arguments.

Change History (8)

This ticket was mentioned in PR #3680 on WordPress/wordpress-develop by felipelavinz.


2 years ago
#1

  • Keywords has-patch added

Add hierarchical = 0 to the get_pages() call on WP_Customize_Manager::has_published_pages() so the check doesn't fail when the queried page is not top-level.

Trac ticket: https://core.trac.wordpress.org/ticket/57198

#2 @dlh
2 years ago

  • Milestone changed from Awaiting Review to 6.2
  • Version changed from trunk to 6.0

Welcome back to Trac, @felipelavinz, and thanks for the report!

I've been able to replicate this bug on a new installation using these steps:

  1. Switch to the Twenty Twenty theme.
  2. Publish the draft "Privacy Policy" page, and make it a child of "Sample Page"
  3. Open the Customizer, and observe that the "Homepage Settings" section is missing.

The fix in the PR makes sense to me and works in my testing. Marking for 6.2 consideration.

#3 @felipelavinz
2 years ago

Thank you, I'm glad to help!

Let me know if there's anything else I can do, it would be great to have this fix for 6.2 :-)

#4 @costdev
2 years ago

  • Keywords has-testing-info added

Test Report

Patch tested: https://github.com/WordPress/wordpress-develop/pull/3680/

Steps to Reproduce or Test

  1. Switch to the Twenty Twenty theme.
  2. Publish the draft "Privacy Policy" page, and make it a child of "Sample Page".
  3. 🐞 Navigate to Appearance > Customize.

Expected Results

When reproducing a bug:

  • ❌ The "Homepage Settings" section should be missing.

When testing a patch to validate it works as expected:

  • ✅ The "Homepage Settings" section should be available.

Environment

  • Server: Apache (Linux)
  • WordPress: 6.1.1
  • Browser: Chrome 107.0.0.0
  • OS: Windows 10
  • Theme: Twenty Twenty
  • Plugins: None activated

Actual Results

When reproducing a bug/defect:

  • ❌ Issue reproduced. The "Homepage Settings" section is missing.

When testing the bugfix patch:

  • ✅ Patch resolves the issue. The "Homepage Settings" section is available.

Notes

  • The patch works as expected. Adding for commit consideration.

#5 @costdev
2 years ago

  • Keywords commit added

#6 @audrasjb
2 years ago

  • Owner set to audrasjb
  • Status changed from new to accepted

Thank for the patch @felipelavinz and for the test cases @dlh and @costdev ✌️
I can reproduce the error and the patch fixes the issue on my case.
Self assigning for commit.

#7 @audrasjb
2 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 54935:

Customize: Fix a wrong condition on WP_Customize_Manager::has_published_pages().

The Homepage Settings section on the customizer uses WP_Customize_Manager::has_published_pages() as active_callback. [53057] introduced an error on the logical check when the queried page is not a top-level page, which leads has_published_pages to incorrectly return an empty array.

This changeset fixes the issue by adding 'hierarchical' => 0 to get_pages() arguments.

Follow-up to [53057].

Props felipelavinz, dlh, costdev.
Fixes #57198.

Note: See TracTickets for help on using tickets.