#58999 closed defect (bug) (invalid)
wpdb set_Sql_mode array key bug
Reported by: | macitemre | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9 |
Component: | Database | Keywords: | |
Focuses: | Cc: |
Description
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.
Change History (3)
#1
@
14 months ago
- Focuses sustainability removed
- Version changed from 6.2.2 to 3.9
Version 0, edited 14 months ago
by
(next)
Note: See
TracTickets for help on using
tickets.
Hi there, welcome to WordPress Trac! Thanks for the report.
Unless I'm missing something, the
foreach
loop only unsets those entries of the$modes
array which are present in the$incompatible_modes
array, the order of elements in both arrays should not matter.Could you provide the steps to reproduce it on a clean install?
Introduced in [27072] / #26847, setting the version accordingly.