diff --git a/wp-includes/post.php b/wp-includes/post.php index 74cedc40e1..8cb7287289 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -6061,9 +6061,9 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { $revparts = array_reverse( $parts ); - $foundid = 0; + $found_id = 0; foreach ( (array) $pages as $page ) { - if ( $page->post_name == $revparts[0] ) { + if ( $page->post_name === $revparts[0] ) { $count = 0; $p = $page; @@ -6071,18 +6071,21 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { * Loop through the given path parts from right to left, * ensuring each matches the post ancestry. */ - while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) { + while ( 0 !== (int) $p->post_parent && isset( $pages[ $p->post_parent ] ) ) { ++$count; $parent = $pages[ $p->post_parent ]; - if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) { + if ( ! isset( $revparts[ $count ] ) || $parent->post_name !== $revparts[ $count ] ) { break; } $p = $parent; } - if ( 0 == $p->post_parent && count( $revparts ) === $count + 1 && $p->post_name == $revparts[ $count ] ) { - $foundid = $page->ID; - if ( $page->post_type == $post_type ) { + if ( 0 === (int) $p->post_parent + && count( $revparts ) === $count + 1 + && $p->post_name === $revparts[ $count ] + ) { + $found_id = $page->ID; + if ( $page->post_type === $post_type ) { break; } } @@ -6090,10 +6093,10 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { } // We cache misses as well as hits. - wp_cache_set( $cache_key, $foundid, 'post-queries' ); + wp_cache_set( $cache_key, $found_id, 'post-queries' ); - if ( $foundid ) { - return get_post( $foundid, $output ); + if ( $found_id ) { + return get_post( $found_id, $output ); } return null; diff --git a/wp-includes/version.php b/wp-includes/version.php index 0106be95fd..3da2fb655d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59598'; +$wp_version = '6.8-alpha-59599'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.