Skip to content

Commit

Permalink
Revert to pre-4.7 behavior for fetching object instances by id.
Browse files Browse the repository at this point in the history
This changeset reverts [38381], which caused inconsistencies in the way the
REST API fetches posts and other objects.

Merge of [39992] to the 4.7 branch.

See #38792, #37738.

Built from https://develop.svn.wordpress.org/branches/4.7@39993


git-svn-id: http://core.svn.wordpress.org/branches/4.7@39930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
boonebgorges committed Jan 26, 2017
1 parent fa47298 commit 89d7d9e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
5 changes: 2 additions & 3 deletions wp-includes/class-wp-comment.php
Expand Up @@ -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 ) {
Expand Down
5 changes: 2 additions & 3 deletions wp-includes/class-wp-post.php
Expand Up @@ -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 ) {
Expand Down
5 changes: 2 additions & 3 deletions wp-includes/class-wp-term.php
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7.2-alpha-39990';
$wp_version = '4.7.2-alpha-39993';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 89d7d9e

Please sign in to comment.