mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
Don't improperly cast IDs when fetching post, user, or term objects.
Blindly casting passed IDs to integers can generate false positives when the ID is cast to `1`. Props deeptiboddapati. Fixes #37738. Built from https://develop.svn.wordpress.org/trunk@38381 git-svn-id: http://core.svn.wordpress.org/trunk@38322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
11216c7069
commit
0b81d79c86
@ -191,11 +191,12 @@ final class WP_Comment {
|
|||||||
public static function get_instance( $id ) {
|
public static function get_instance( $id ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$comment_id = (int) $id;
|
if ( ! is_numeric( $id ) || $id != floor( $id ) || ! $id ) {
|
||||||
if ( ! $comment_id ) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$comment_id = (int) $id;
|
||||||
|
|
||||||
$_comment = wp_cache_get( $comment_id, 'comment' );
|
$_comment = wp_cache_get( $comment_id, 'comment' );
|
||||||
|
|
||||||
if ( ! $_comment ) {
|
if ( ! $_comment ) {
|
||||||
|
@ -210,9 +210,11 @@ final class WP_Post {
|
|||||||
public static function get_instance( $post_id ) {
|
public static function get_instance( $post_id ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$post_id = (int) $post_id;
|
if ( ! is_numeric( $post_id ) || $post_id != floor( $post_id ) || ! $post_id ) {
|
||||||
if ( ! $post_id )
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_id = (int) $post_id;
|
||||||
|
|
||||||
$_post = wp_cache_get( $post_id, 'posts' );
|
$_post = wp_cache_get( $post_id, 'posts' );
|
||||||
|
|
||||||
|
@ -125,11 +125,12 @@ final class WP_Term {
|
|||||||
public static function get_instance( $term_id, $taxonomy = null ) {
|
public static function get_instance( $term_id, $taxonomy = null ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$term_id = (int) $term_id;
|
if ( ! is_numeric( $term_id ) || $term_id != floor( $term_id ) || ! $term_id ) {
|
||||||
if ( ! $term_id ) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$term_id = (int) $term_id;
|
||||||
|
|
||||||
$_term = wp_cache_get( $term_id, 'terms' );
|
$_term = wp_cache_get( $term_id, 'terms' );
|
||||||
|
|
||||||
// If there isn't a cached version, hit the database.
|
// If there isn't a cached version, hit the database.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7-alpha-38380';
|
$wp_version = '4.7-alpha-38381';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user