Skip to content

Commit

Permalink
Merge branch 'trunk' of git://core.git.wordpress.org into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
gilzow committed Jan 12, 2025
2 parents ba77934 + dfdb440 commit ca092f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -6061,39 +6061,42 @@ 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;

/*
* 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;
}
}
}
}

// 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;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ca092f7

Please sign in to comment.