Make WordPress Core

Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#58999 closed defect (bug) (invalid)

wpdb set_Sql_mode array key bug

Reported by: macitemre's profile macitemre Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Database Keywords:
Focuses: Cc:



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


Change History (3)

#1 @SergeyBiryukov
11 months ago

  • Focuses sustainability removed
  • Version changed from 6.2.2 to 3.9

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.

Version 0, edited 11 months ago by SergeyBiryukov (next)

#2 @macitemre
11 months ago

  • Resolution set to invalid
  • Status changed from new to closed

my mistake : i have mixed NO_ZERO_IN_DATE with NO_ZERO_DATE for about 2 hours.

sorry for inconvenience.

#3 @SergeyBiryukov
11 months ago

  • Milestone Awaiting Review deleted

No worries, thanks for the follow-up!

Note: See TracTickets for help on using tickets.