[wp-trac] [WordPress Trac] #39075: wpdb return type constants broken in 4.7 RC2 - always returns ARRAY_N

WordPress Trac noreply at wordpress.org
Sun Dec 4 21:03:05 UTC 2016


#39075: wpdb return type constants broken in 4.7 RC2 - always returns ARRAY_N
--------------------------+-----------------------------
 Reporter:  sterndata     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Given this code:

 {{{#!php
 <?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
         )

 )
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39075>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list