Skip to content

Commit 6ae2b31

Browse files
authored
Merged 105 - Modern MySQL compatibility
Automattic#105
1 parent 09c9624 commit 6ae2b31

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Diff for: db.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ public function db_connect( $query = '' ) {
435435
if ( ! $this->ex_mysql_select_db( DB_NAME, $this->dbh ) ) {
436436
return $this->log_and_bail( 'We were unable to select the database' );
437437
}
438+
439+
// Set the SQL mode.
440+
if ( is_callable( array( $this, 'set_sql_mode' ) ) ) {
441+
$this->set_sql_mode();
442+
}
443+
438444
if ( ! empty( $this->charset ) ) {
439445
$collation_query = "SET NAMES '$this->charset'";
440446
if ( ! empty( $this->collate ) ) {
@@ -781,8 +787,13 @@ public function db_connect( $query = '' ) {
781787

782788
$this->set_charset( $this->dbhs[ $dbhname ], $charset, $collate );
783789

784-
$this->dbh = $this->dbhs[ $dbhname ]; // needed by $wpdb->_real_escape()
785-
790+
$this->dbh = $this->dbhs[ $dbhname ]; // needed by $wpdb->_real_escape() and `$wpdb->set_sql_mode()`
791+
792+
// Set the SQL mode.
793+
if ( is_callable( array( $this, 'set_sql_mode' ) ) ) {
794+
$this->set_sql_mode();
795+
}
796+
786797
$this->last_used_server = compact( 'host', 'user', 'name', 'read', 'write' );
787798

788799
$this->used_servers[ $dbhname ] = $this->last_used_server;

0 commit comments

Comments
 (0)