Ticket #45299: 45299.2.diff
| File 45299.2.diff, 1.3 KB (added by , 7 years ago) |
|---|
-
src/wp-includes/wp-db.php
2456 2456 2457 2457 $new_array = array(); 2458 2458 // Extract the column values 2459 for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) { 2460 $new_array[$i] = $this->get_var( null, $x, $i ); 2459 if ( $this->last_result ) { 2460 for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) { 2461 $new_array[ $i ] = $this->get_var( null, $x, $i ); 2462 } 2461 2463 } 2462 2464 return $new_array; 2463 2465 } … … 2497 2499 } elseif ( $output == OBJECT_K ) { 2498 2500 // Return an array of row objects with keys from column 1 2499 2501 // (Duplicates are discarded) 2500 foreach ( $this->last_result as $row ) { 2501 $var_by_ref = get_object_vars( $row ); 2502 $key = array_shift( $var_by_ref ); 2503 if ( ! isset( $new_array[ $key ] ) ) 2504 $new_array[ $key ] = $row; 2502 if ( $this->last_result ) { 2503 foreach ( $this->last_result as $row ) { 2504 $var_by_ref = get_object_vars( $row ); 2505 $key = array_shift( $var_by_ref ); 2506 if ( ! isset( $new_array[ $key ] ) ) { 2507 $new_array[ $key ] = $row; 2508 } 2509 } 2505 2510 } 2506 2511 return $new_array; 2507 2512 } elseif ( $output == ARRAY_A || $output == ARRAY_N ) {