From 34f2b9c6ee4a55773d513a0500b712c8c6b9d10e Mon Sep 17 00:00:00 2001 From: saratheonline Date: Thu, 9 Apr 2026 11:03:53 +0530 Subject: [PATCH] Posts, Post Types: Fix missing array check in get_post_custom_values(). Posts, Post Types: Fix missing array check in get_post_custom_values(). `get_post_custom()` can return `false` for an invalid post ID or an empty string for a non-existing post. `get_post_custom_values()` accessed the result as an array without first verifying it is one, triggering a PHP warning on PHP 8+. Adds an `is_array()` guard consistent with the sibling function `get_post_custom_keys()`, which already handles this case correctly. --- src/wp-includes/post.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index b225d35c48b2a..242f80cf039ad 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -2891,6 +2891,10 @@ function get_post_custom_values( $key = '', $post_id = 0 ) { $custom = get_post_custom( $post_id ); + if ( ! is_array( $custom ) ) { + return null; + } + return $custom[ $key ] ?? null; }