Commit 8217ac4b68 for wordpress.org
commit 8217ac4b686e0f57039c8f054e34a43e57d52836
Author: westonruter <westonruter@git.wordpress.org>
Date: Wed Dec 2 19:51:58 2026 +0000
Code Quality: Resolve the strict cast.int PHPStan error.
In `WP_Post::get_instance()` the post row fetched from the database was cached under `(int) $_post->ID`, which PHPStan reports as a cast of mixed at level 10, since `$wpdb->get_row()` returns a plain object. The row is now cached under `$post_id`, the requested ID by which it was queried, as `WP_Term`, `WP_Site`, and `WP_Network` already do. Behavior is unchanged, since `$post_id` has already been cast to an integer and checked to be positive, so it always equals the row's `ID`. This empties the strict cast.int baseline, so it is removed.
Developed in https://github.com/WordPress/wordpress-develop/pull/16366.
Follow-up to r62648, r63354, r65668.
Props hmbashar, lancewillett, mukesh27.
See #66739.
Built from https://develop.svn.wordpress.org/trunk@65865
git-svn-id: http://core.svn.wordpress.org/trunk@64894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/class-wp-post.php b/wp-includes/class-wp-post.php
index 002d83a424..9bc294ea8c 100644
--- a/wp-includes/class-wp-post.php
+++ b/wp-includes/class-wp-post.php
@@ -297,7 +297,7 @@ final class WP_Post {
$_post = sanitize_post( $_post, 'raw' );
// Not wp_cache_add(), since an unusable cached value may still be present and must be replaced.
- wp_cache_set( (int) $_post->ID, $_post, 'posts' );
+ wp_cache_set( $post_id, $_post, 'posts' );
} elseif ( empty( $_post->filter ) || 'raw' !== $_post->filter ) {
$_post = sanitize_post( $_post, 'raw' );
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 434cf35499..d984ff6330 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.3-alpha-65864';
+$wp_version = '7.3-alpha-65865';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.