From fe8462294ab388e2aeaf445c88fac42fdfb65bfd Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Thu, 11 Mar 2010 21:30:29 +0000 Subject: [PATCH] Ensure that wpdb::get_results() always returns an array when it should. Fixes #10607 props miqrogroove. git-svn-id: https://develop.svn.wordpress.org/trunk@13671 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/wp-db.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index c6d1e051d8..cefc282e0e 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -444,6 +444,15 @@ class wpdb { */ var $dbuser; + /** + * A textual description of the last query/get_row/get_var call + * + * @since unknown + * @access public + * @var string + */ + var $func_call; + /** * Connects to the database server and selects a database * @@ -1387,20 +1396,19 @@ class wpdb { } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { // Return an integer-keyed array of... if ( $this->last_result ) { - $i = 0; foreach( (array) $this->last_result as $row ) { if ( $output == ARRAY_N ) { // ...integer-keyed row arrays - $new_array[$i] = array_values( get_object_vars( $row ) ); + $new_array[] = array_values( get_object_vars( $row ) ); } else { // ...column name-keyed row arrays - $new_array[$i] = get_object_vars( $row ); + $new_array[] = get_object_vars( $row ); } - ++$i; } - return $new_array; } + return $new_array; } + return null; } /** @@ -1569,4 +1577,4 @@ if ( ! isset($wpdb) ) { */ $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); } -?> +?> \ No newline at end of file