From 04747a1a914fb49d5c18a36f994c645b636baa06 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Wed, 7 Aug 2024 19:47:10 +0000 Subject: [PATCH] General: Cast `$max_depth` and `$depth` to an integer in the `Walker` class. This ensures that the arguments are correctly interpreted when passed as a query string, i.e. when `wp_parse_args()` is involved. For example, `wp_list_pages( 'depth=0' )` should display a list of all pages to the maximum depth. Follow-up to [57848]. Reviewed by peterwilsoncc. Merges [58812] to the 6.6 branch. Props freibergergarcia, peterwilsoncc, ahortin. Fixes #61749. Built from https://develop.svn.wordpress.org/branches/6.6@58863 git-svn-id: http://core.svn.wordpress.org/branches/6.6@58259 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-walker.php | 15 +++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wp-includes/class-wp-walker.php b/wp-includes/class-wp-walker.php index ff5eac2f50..df67921c27 100644 --- a/wp-includes/class-wp-walker.php +++ b/wp-includes/class-wp-walker.php @@ -135,6 +135,9 @@ class Walker { return; } + $max_depth = (int) $max_depth; + $depth = (int) $depth; + $id_field = $this->db_fields['id']; $id = $element->$id_field; @@ -191,6 +194,8 @@ class Walker { public function walk( $elements, $max_depth, ...$args ) { $output = ''; + $max_depth = (int) $max_depth; + // Invalid parameter or nothing to walk. if ( $max_depth < -1 || empty( $elements ) ) { return $output; @@ -285,12 +290,14 @@ class Walker { * @return string XHTML of the specified page of elements. */ public function paged_walk( $elements, $max_depth, $page_num, $per_page, ...$args ) { - if ( empty( $elements ) || $max_depth < -1 ) { - return ''; - } - $output = ''; + $max_depth = (int) $max_depth; + + if ( empty( $elements ) || $max_depth < -1 ) { + return $output; + } + $parent_field = $this->db_fields['parent']; $count = -1; diff --git a/wp-includes/version.php b/wp-includes/version.php index e7d9bd91c8..a13ff40440 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6.2-alpha-58862'; +$wp_version = '6.6.2-alpha-58863'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.