#39075 closed defect (bug) (invalid)
wpdb return type constants broken in 4.7 RC2 - always returns ARRAY_N
Reported by: | sterndata | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.7 |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description
Given this code:
<?php <?php include_once( 'wp-load.php' ); $query = 'select `ID` from sds_wp_posts LIMIT 0,2'; echo "OBJECT"; $result = $wpdb->get_results( $query, OBJECT ); echo '<pre>'; print_r( $result ); echo '</pre>'; echo "ARRAY_A"; $result = $wpdb->get_results( $query, ARRAY_A ); echo '<pre>'; print_r( $result ); echo '</pre>'; echo "ARRAY_N"; $result = $wpdb->get_results( $query, ARRAY_N ); echo '<pre>'; print_r( $result ); echo '</pre>';
Result are OK in 4.6.1
OBJECT Array ( [0] => stdClass Object ( [ID] => 1 ) [1] => stdClass Object ( [ID] => 2 ) ) ARRAY_A Array ( [0] => Array ( [ID] => 1 ) [1] => Array ( [ID] => 2 ) ) ARRAY_N Array ( [0] => Array ( [0] => 1 ) [1] => Array ( [0] => 2 ) )
but incorrect in 4.7 RC2
OBJECT Array ( [0] => stdClass Object ( [ID] => 6 ) [1] => stdClass Object ( [ID] => 8 ) ) ARRAY_A Array ( [0] => Array ( [ID] => 6 ) [1] => Array ( [ID] => 8 ) ) ARRAY_N Array ( [0] => Array ( [0] => 6 ) [1] => Array ( [0] => 8 ) )
Change History (9)
#2
@
8 years ago
- Keywords reporter-feedback added
- Resolution invalid deleted
- Status changed from closed to reopened
Seems like the ticket was closed accidentally.
@sterndata Can you give use some more information, perhaps in form of unit tests? What version of PHP are you using?
#4
@
8 years ago
- Component changed from Database to Query
- Resolution set to invalid
- Status changed from reopened to closed
Please ignore this ticket. I misread things.
#6
@
8 years ago
Hi pals,
Thought this one was deleted yesterday, sterndata was supposed to repost it or something, anyway, this has to be fixed as soon as possible, I don't have a unit test, just try the sample sterndata has provided, it's always ARRAY_N (ignore the 2nd output sample).
#7
@
8 years ago
the output is identical on 4.6 and 4.7RC2 -- I was wrong.
http://devbase.sterndata.com/test.php (4.6)
https://www.stevenstern.me/test.php (4.7 RC2)
Note: See
TracTickets for help on using
tickets.
Correction: I mis-pasted. The first example should be the correct ouptput:
OBJECT
Array
(
)
ARRAY_A
Array
(
)
ARRAY_N
Array
(
)