Run parse_query() in get_posts() so that the query vars are always parsed for set(), get_posts() patterns. fixes #16545 for trunk

git-svn-id: https://develop.svn.wordpress.org/trunk@17451 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2011-02-15 23:57:13 +00:00
parent 2394a8d68d
commit db31b732eb

View File

@ -1312,7 +1312,7 @@ class WP_Query {
* @access public * @access public
*/ */
function parse_query_vars() { function parse_query_vars() {
$this->parse_query(''); $this->parse_query();
} }
/** /**
@ -1383,12 +1383,14 @@ class WP_Query {
* @since 1.5.0 * @since 1.5.0
* @access public * @access public
* *
* @param string|array $query * @param string|array $query Optional query.
*/ */
function parse_query($query) { function parse_query( $query = '' ) {
if ( !empty($query) || !isset($this->query) ) { if ( ! empty( $query ) ) {
$this->init(); $this->init();
$this->query = $this->query_vars = wp_parse_args($query); $this->query = $this->query_vars = wp_parse_args( $query );
} elseif ( ! isset( $this->query ) ) {
$this->query = $this->query_vars;
} }
$this->query_vars = $this->fill_query_vars($this->query_vars); $this->query_vars = $this->fill_query_vars($this->query_vars);
@ -1871,6 +1873,8 @@ class WP_Query {
function &get_posts() { function &get_posts() {
global $wpdb, $user_ID, $_wp_using_ext_object_cache; global $wpdb, $user_ID, $_wp_using_ext_object_cache;
$this->parse_query();
do_action_ref_array('pre_get_posts', array(&$this)); do_action_ref_array('pre_get_posts', array(&$this));
// Shorthand. // Shorthand.
@ -2851,8 +2855,9 @@ class WP_Query {
* @param string $query URL query string. * @param string $query URL query string.
* @return array List of posts. * @return array List of posts.
*/ */
function &query($query) { function &query( $query ) {
$this->parse_query($query); $this->init();
$this->query = $this->query_vars = wp_parse_args( $query );
return $this->get_posts(); return $this->get_posts();
} }