From fe1e3dba984ad682f8da36c11e3db027934176f6 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 26 Jan 2017 16:53:41 +0000 Subject: [PATCH] Revert to pre-4.7 behavior for fetching object instances by id. This changeset reverts [38381], which caused inconsistencies in the way the REST API fetches posts and other objects. See #38792, #37738. Built from https://develop.svn.wordpress.org/trunk@39992 git-svn-id: http://core.svn.wordpress.org/trunk@39929 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-comment.php | 5 ++--- wp-includes/class-wp-post.php | 5 ++--- wp-includes/class-wp-term.php | 5 ++--- wp-includes/version.php | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/wp-includes/class-wp-comment.php b/wp-includes/class-wp-comment.php index 80ef9bb1d3..0e9f88a352 100644 --- a/wp-includes/class-wp-comment.php +++ b/wp-includes/class-wp-comment.php @@ -191,12 +191,11 @@ final class WP_Comment { public static function get_instance( $id ) { global $wpdb; - if ( ! is_numeric( $id ) || $id != floor( $id ) || ! $id ) { + $comment_id = (int) $id; + if ( ! $comment_id ) { return false; } - $comment_id = (int) $id; - $_comment = wp_cache_get( $comment_id, 'comment' ); if ( ! $_comment ) { diff --git a/wp-includes/class-wp-post.php b/wp-includes/class-wp-post.php index c966934899..edaf149a3f 100644 --- a/wp-includes/class-wp-post.php +++ b/wp-includes/class-wp-post.php @@ -210,12 +210,11 @@ final class WP_Post { public static function get_instance( $post_id ) { global $wpdb; - if ( ! is_numeric( $post_id ) || $post_id != floor( $post_id ) || ! $post_id ) { + $post_id = (int) $post_id; + if ( ! $post_id ) { return false; } - $post_id = (int) $post_id; - $_post = wp_cache_get( $post_id, 'posts' ); if ( ! $_post ) { diff --git a/wp-includes/class-wp-term.php b/wp-includes/class-wp-term.php index 6cb4a15bd8..8eb87efbe0 100644 --- a/wp-includes/class-wp-term.php +++ b/wp-includes/class-wp-term.php @@ -125,12 +125,11 @@ final class WP_Term { public static function get_instance( $term_id, $taxonomy = null ) { global $wpdb; - if ( ! is_numeric( $term_id ) || $term_id != floor( $term_id ) || ! $term_id ) { + $term_id = (int) $term_id; + if ( ! $term_id ) { return false; } - $term_id = (int) $term_id; - $_term = wp_cache_get( $term_id, 'terms' ); // If there isn't a cached version, hit the database. diff --git a/wp-includes/version.php b/wp-includes/version.php index e122dc4cc1..bb8b20833f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-39991'; +$wp_version = '4.8-alpha-39992'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.