Make WordPress Core

Changeset 65865


Ignore:
Timestamp:
12/02/2026 07:50:03 PM (2 days ago)
Author:
westonruter
Message:

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.

Location:
trunk
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-post.php

    r65534 r65865  
    298298
    299299                        // Not wp_cache_add(), since an unusable cached value may still be present and must be replaced.
    300                         wp_cache_set( (int) $_post->ID, $_post, 'posts' );
     300                        wp_cache_set( $post_id, $_post, 'posts' );
    301301                } elseif ( empty( $_post->filter ) || 'raw' !== $_post->filter ) {
    302302                        $_post = sanitize_post( $_post, 'raw' );
Note: See TracChangeset for help on using the changeset viewer.