From a6b9d323c6477bb406824e048ed9034d38ecc958 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 24 Mar 2014 18:55:16 +0000 Subject: [PATCH] When using WP_Query's `"fields" => "ids"` (or `"fields" => "id=>parent"`), the returned values should be an array of integers, not array of integers represented by strings. Adds unit tests. All other unit tests pass. Props danielbachhuber. Fixes #27252. Built from https://develop.svn.wordpress.org/trunk@27686 git-svn-id: http://core.svn.wordpress.org/trunk@27525 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 2adf7d2168..05d4979d4f 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2268,7 +2268,7 @@ class WP_Query { // This overrides posts_per_page. if ( ! empty( $q['posts_per_rss'] ) ) { $q['posts_per_page'] = $q['posts_per_rss']; - } else { + } else { $q['posts_per_page'] = get_option( 'posts_per_rss' ); } $q['nopaging'] = false; @@ -3205,7 +3205,7 @@ class WP_Query { $this->post_count = count( $this->posts ); $this->set_found_posts( $q, $limits ); - return $this->posts; + return array_map( 'intval', $this->posts ); } if ( 'id=>parent' == $q['fields'] ) { @@ -3214,9 +3214,9 @@ class WP_Query { $this->set_found_posts( $q, $limits ); $r = array(); - foreach ( $this->posts as $post ) - $r[ $post->ID ] = $post->post_parent; - + foreach ( $this->posts as $post ) { + $r[ (int) $post->ID ] = (int) $post->post_parent; + } return $r; }