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. Built from https://develop.svn.wordpress.org/trunk@59337 git-svn-id: http://core.svn.wordpress.org/trunk@58723 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5ef0c89c61
commit
2dfcb9ea56
|
@ -351,14 +351,16 @@ final class WP_Comment {
|
|||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param string $name Property name.
|
||||
* @return bool
|
||||
* @param string $name Property to check if set.
|
||||
* @return bool Whether the property is set.
|
||||
*/
|
||||
public function __isset( $name ) {
|
||||
if ( in_array( $name, $this->post_fields, true ) && 0 !== (int) $this->comment_post_ID ) {
|
||||
$post = get_post( $this->comment_post_ID );
|
||||
return property_exists( $post, $name );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4011,6 +4011,8 @@ class WP_Query {
|
|||
if ( in_array( $name, $this->compat_fields, true ) ) {
|
||||
return isset( $this->$name );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.8-alpha-59336';
|
||||
$wp_version = '6.8-alpha-59337';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue