Commit 2dfcb9ea56 for wordpress.org
commit 2dfcb9ea56616bd0d5cdf36a215b2eebb0052fb4
Author: Sergey Biryukov <sergeybiryukov.ru@gmail.com>
Date: Sun Nov 3 23:03:19 2024 +0000
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
diff --git a/wp-includes/class-wp-comment.php b/wp-includes/class-wp-comment.php
index 996815939d..c5a0bd9aaf 100644
--- a/wp-includes/class-wp-comment.php
+++ b/wp-includes/class-wp-comment.php
@@ -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;
}
/**
diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php
index d25493dc5c..bc673191a8 100644
--- a/wp-includes/class-wp-query.php
+++ b/wp-includes/class-wp-query.php
@@ -4011,6 +4011,8 @@ class WP_Query {
if ( in_array( $name, $this->compat_fields, true ) ) {
return isset( $this->$name );
}
+
+ return false;
}
/**
diff --git a/wp-includes/version.php b/wp-includes/version.php
index b37a9890fe..aa3238388b 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -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.