[wp-trac] [WordPress Trac] #58999: wpdb set_Sql_mode array key bug

WordPress Trac noreply at wordpress.org
Tue Aug 8 00:20:18 UTC 2023


#58999: wpdb set_Sql_mode array key bug
----------------------------+-----------------------------
 Reporter:  macitemre       |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Database        |    Version:  6.2.2
 Severity:  normal          |   Keywords:
  Focuses:  sustainability  |
----------------------------+-----------------------------
 hi,

 in class.wpdb.php inside set_sql_mode function, when $modes is empty
 array,
 $modes array keys are numerical (as $modes = explode( ',', $modes_str );
 is numerical indiced array) inside foreach

 {{{
 foreach ( $modes as $i => $mode ) {
         if ( in_array( $mode, $incompatible_modes, true ) ) {
                 echo "<hr>";
                 echo "unset : ".$mode;
                 unset( $modes[ $i ] );
         }
 }
 }}}
 when $modes are differently sorted other from $incompatible_modes, the
 unset process with indice unsets randomly. Thus, sets sql_mode other than
 wanted.

 $modes must be string associated array to make it work.

 i am using php 8.2 with mysql 8.0

 thanks.

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


More information about the wp-trac mailing list