WPDB: Remove the addition of STRICT_ALL_TABLES, added in [30400]. This proved to be incompatible with too many plugins, as well as being incompatible with MySQL 5.7.

See #21212.

Built from https://develop.svn.wordpress.org/trunk@30587


git-svn-id: http://core.svn.wordpress.org/trunk@30577 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2014-11-27 11:00:23 +00:00
parent 4d651b90bb
commit 8990b1c1fc
2 changed files with 33 additions and 36 deletions

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-beta2-30586';
$wp_version = '4.1-beta2-30587';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -566,16 +566,8 @@ class wpdb {
* @access protected
* @var array
*/
protected $incompatible_modes = array( 'NO_ZERO_DATE', 'ONLY_FULL_GROUP_BY', 'TRADITIONAL' );
/**
* A list of required SQL modes.
*
* @since 4.1.0
* @access protected
* @var array
*/
protected $required_modes = array( 'STRICT_ALL_TABLES' );
protected $incompatible_modes = array( 'NO_ZERO_DATE', 'ONLY_FULL_GROUP_BY',
'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'TRADITIONAL' );
/**
* Whether to use mysqli over mysql.
@ -786,12 +778,31 @@ class wpdb {
*/
public function set_sql_mode( $modes = array() ) {
if ( empty( $modes ) ) {
$modes = $this->get_var( "SELECT @@SESSION.sql_mode" );
if ( $modes ) {
$modes = $original_modes = explode( ',', $modes );
if ( $this->use_mysqli ) {
$res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' );
} else {
$modes = $original_modes = array();
$res = mysql_query( 'SELECT @@SESSION.sql_mode', $this->dbh );
}
if ( empty( $res ) ) {
return;
}
if ( $this->use_mysqli ) {
$modes_array = mysqli_fetch_array( $res );
if ( empty( $modes_array[0] ) ) {
return;
}
$modes_str = $modes_array[0];
} else {
$modes_str = mysql_result( $res, 0 );
}
if ( empty( $modes_str ) ) {
return;
}
$modes = explode( ',', $modes_str );
}
$modes = array_change_key_case( $modes, CASE_UPPER );
@ -805,32 +816,18 @@ class wpdb {
*/
$incompatible_modes = (array) apply_filters( 'incompatible_sql_modes', $this->incompatible_modes );
/**
* Filter the list of required SQL modes to include.
*
* @since 4.1.0
*
* @param array $required_modes An array of required modes.
*/
$required_modes = (array) apply_filters( 'required_sql_modes', $this->required_modes );
$modes = array_diff( $modes, $incompatible_modes );
$modes = array_unique( array_merge( $modes, $required_modes ) );
// Don't run SET SESSION if we have nothing to change.
if ( isset( $original_modes ) ) {
sort( $original_modes );
sort( $modes );
if ( $original_modes === $modes ) {
return;
foreach( $modes as $i => $mode ) {
if ( in_array( $mode, $incompatible_modes ) ) {
unset( $modes[ $i ] );
}
}
$modes_str = implode( ',', $modes );
$this->query( "SET SESSION sql_mode='$modes_str'" );
if ( $this->last_error ) {
dead_db();
if ( $this->use_mysqli ) {
mysqli_query( $this->dbh, "SET SESSION sql_mode='$modes_str'" );
} else {
mysql_query( "SET SESSION sql_mode='$modes_str'", $this->dbh );
}
}