Make WordPress Core

Changeset 59599


Ignore:
Timestamp:
01/12/2025 06:12:14 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in get_page_by_path().

Follow-up to [3511], [18541], [19075], [21845].

Props aristath, poena, afercia, SergeyBiryukov.
See #62279.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r59597 r59599  
    60626062    $revparts = array_reverse( $parts );
    60636063
    6064     $foundid = 0;
     6064    $found_id = 0;
    60656065    foreach ( (array) $pages as $page ) {
    6066         if ( $page->post_name == $revparts[0] ) {
     6066        if ( $page->post_name === $revparts[0] ) {
    60676067            $count = 0;
    60686068            $p     = $page;
     
    60726072             * ensuring each matches the post ancestry.
    60736073             */
    6074             while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
     6074            while ( 0 !== (int) $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
    60756075                ++$count;
    60766076                $parent = $pages[ $p->post_parent ];
    6077                 if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
     6077                if ( ! isset( $revparts[ $count ] ) || $parent->post_name !== $revparts[ $count ] ) {
    60786078                    break;
    60796079                }
     
    60816081            }
    60826082
    6083             if ( 0 == $p->post_parent && count( $revparts ) === $count + 1 && $p->post_name == $revparts[ $count ] ) {
    6084                 $foundid = $page->ID;
    6085                 if ( $page->post_type == $post_type ) {
     6083            if ( 0 === (int) $p->post_parent
     6084                && count( $revparts ) === $count + 1
     6085                && $p->post_name === $revparts[ $count ]
     6086            ) {
     6087                $found_id = $page->ID;
     6088                if ( $page->post_type === $post_type ) {
    60866089                    break;
    60876090                }
     
    60916094
    60926095    // We cache misses as well as hits.
    6093     wp_cache_set( $cache_key, $foundid, 'post-queries' );
    6094 
    6095     if ( $foundid ) {
    6096         return get_post( $foundid, $output );
     6096    wp_cache_set( $cache_key, $found_id, 'post-queries' );
     6097
     6098    if ( $found_id ) {
     6099        return get_post( $found_id, $output );
    60976100    }
    60986101
Note: See TracChangeset for help on using the changeset viewer.