Skip to content

Commit 78602b4

Browse files
Coding Standards: Explicitly return false in magic __isset() methods.
This commit fixes an issue where some magic `__isset()` methods were potentially returning `void` (if the prop is not in an allow-listed array of fields) instead of an explicit boolean `false`. Addressed methods: * `WP_Comment::__isset()` * `WP_Query::__isset()` Follow-up to [28523], [31151], [34583], [34599]. Props justlevine. See #52217. git-svn-id: https://develop.svn.wordpress.org/trunk@59337 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0a45a6c commit 78602b4

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/wp-includes/class-wp-comment.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,16 @@ public function populated_children( $set ) {
351351
*
352352
* @since 4.4.0
353353
*
354-
* @param string $name Property name.
355-
* @return bool
354+
* @param string $name Property to check if set.
355+
* @return bool Whether the property is set.
356356
*/
357357
public function __isset( $name ) {
358358
if ( in_array( $name, $this->post_fields, true ) && 0 !== (int) $this->comment_post_ID ) {
359359
$post = get_post( $this->comment_post_ID );
360360
return property_exists( $post, $name );
361361
}
362+
363+
return false;
362364
}
363365

364366
/**

src/wp-includes/class-wp-query.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,6 +4011,8 @@ public function __isset( $name ) {
40114011
if ( in_array( $name, $this->compat_fields, true ) ) {
40124012
return isset( $this->$name );
40134013
}
4014+
4015+
return false;
40144016
}
40154017

40164018
/**

0 commit comments

Comments
 (0)