Skip to content

Commit

Permalink
Coding Standards: Use strict comparison in get_post_ancestors().
Browse files Browse the repository at this point in the history
Follow-up to [7074], [15758], [21559], [21953].

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

git-svn-id: https://develop.svn.wordpress.org/trunk@59566 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Dec 30, 2024
1 parent 4e1752d commit 2ba8433
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
function get_post_ancestors( $post ) {
$post = get_post( $post );

if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID ) {
if ( ! $post || empty( $post->post_parent ) || $post->post_parent === $post->ID ) {
return array();
}

Expand All @@ -1146,7 +1146,9 @@ function get_post_ancestors( $post ) {

while ( $ancestor = get_post( $id ) ) {
// Loop detection: If the ancestor has been seen before, break.
if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors, true ) ) {
if ( empty( $ancestor->post_parent ) || $ancestor->post_parent === $post->ID
|| in_array( $ancestor->post_parent, $ancestors, true )
) {
break;
}

Expand Down

0 comments on commit 2ba8433

Please sign in to comment.