Skip to content

Commit 2ba8433

Browse files
Coding Standards: Use strict comparison in get_post_ancestors().
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
1 parent 4e1752d commit 2ba8433

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/wp-includes/post.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,7 @@ function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) {
11351135
function get_post_ancestors( $post ) {
11361136
$post = get_post( $post );
11371137

1138-
if ( ! $post || empty( $post->post_parent ) || $post->post_parent == $post->ID ) {
1138+
if ( ! $post || empty( $post->post_parent ) || $post->post_parent === $post->ID ) {
11391139
return array();
11401140
}
11411141

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

11471147
while ( $ancestor = get_post( $id ) ) {
11481148
// Loop detection: If the ancestor has been seen before, break.
1149-
if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent == $post->ID ) || in_array( $ancestor->post_parent, $ancestors, true ) ) {
1149+
if ( empty( $ancestor->post_parent ) || $ancestor->post_parent === $post->ID
1150+
|| in_array( $ancestor->post_parent, $ancestors, true )
1151+
) {
11501152
break;
11511153
}
11521154

0 commit comments

Comments
 (0)