Opened 5 months ago
Closed 4 months ago
#61749 closed defect (bug) (fixed)
`wp_list_pages()` depth of `0` can show only top level of pages
Reported by: | peterwilsoncc | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.6.2 | Priority: | normal |
Severity: | normal | Version: | 6.6 |
Component: | General | Keywords: | has-patch has-unit-tests fixed-major dev-reviewed |
Focuses: | Cc: |
Description
In WP 6.6, the code wp_list_pages( 'depth=0' );
no longer displays a list of all pages to the maximum depth. Instead only the top level of pages will be displayed.
Steps to reproduce:
- Replace entire theme with
wp_list_pages( 'depth=0' );
- Create a few pages with parent child relationships
- On the latest version of 6.5 a heirachical list of pages will be displayed
- On the 6.6 branch and in trunk the top level pages will only be shown.
The cause is r57848 as the switch to strict comparisons in the walker class does not account for the way wp_parse_args()
handles query string formatted arguments passed to the function and therefore interpreted, eventually, by the walker:
wp> wp_parse_args( 'depth=0', [ 'depth' => 0 ] ); => phar:///usr/local/src/wp-cli/bin/wp/vendor/wp-cli/shell-command/src/WP_CLI/Shell/REPL.php:52: array(1) { 'depth' => string(1) "0" } wp>
I expect this is effecting other functions that make use of the walker class too.
Props @ahortin via the WP Australia Slack for discovery and assistance figuring out reproduction steps.
Change History (7)
This ticket was mentioned in PR #7091 on WordPress/wordpress-develop by @freibergergarcia.
5 months ago
#1
- Keywords has-patch has-unit-tests added
#2
@
5 months ago
See the suggested fix for the issue: https://github.com/WordPress/wordpress-develop/pull/7091.
I added a unit test for depth=0, triggering the wp_parse_args to simulate what was raised.
I also manually tested as suggested above. Hopefully, it will put us in the right direction.
#3
@
5 months ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 58812:
@SergeyBiryukov commented on PR #7091:
5 months ago
#4
Thanks for the PR! Merged in r58812.
Cast $max_depth and $depth to integer on class Walker (class-wp-walker), so it's compliant with strict comparisons.
Trac ticket: https://core.trac.wordpress.org/ticket/61749