Ticket #26847: 26847.2.diff
File 26847.2.diff, 1.7 KB (added by , 11 years ago) |
---|
-
src/wp-includes/wp-db.php
510 510 public $is_mysql = null; 511 511 512 512 /** 513 * A list of MySQL's SQL modes to disable when connecting. 514 * 515 * @since 3.9.0 516 * @see wpdb::set_sql_mode() 517 * @access protected 518 * @var array 519 */ 520 protected $incompatible_modes = array( 'NO_ZERO_DATE', 'ONLY_FULL_GROUP_BY', 521 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'TRADITIONAL' ); 522 523 /** 513 524 * Connects to the database server and selects a database 514 525 * 515 526 * PHP5 style constructor for compatibility with PHP5. Does … … 649 660 } 650 661 651 662 /** 663 * Ensures the connection's sql_mode is WordPress-compatible 664 * 665 * @since 3.9.0 666 * 667 * @param resource $dbh The resource given by mysql_connect 668 */ 669 function set_sql_mode( $dbh ) { 670 $res = mysql_query( 'SELECT @@SESSION.sql_mode;', $dbh ); 671 if ( ! $res ) { 672 return; 673 } 674 675 $modes_str = mysql_result( $res, 0 ); 676 677 if ( empty( $modes_str ) ) { 678 return; 679 } 680 681 $modes = explode( ',', $modes_str ); 682 $modes = array_change_key_case( $modes, CASE_UPPER ); 683 684 foreach( $modes as $i => $mode ) { 685 if ( in_array( $mode, $this->incompatible_modes ) ) { 686 unset( $modes[ $i ] ); 687 } 688 } 689 690 $modes_str = implode( ',', $modes ); 691 692 mysql_query( "SET SESSION sql_mode='$modes_str';", $dbh ); 693 } 694 695 /** 652 696 * Sets the table prefix for the WordPress tables. 653 697 * 654 698 * @since 2.5.0 … … 1170 1214 1171 1215 $this->set_charset( $this->dbh ); 1172 1216 1217 $this->set_sql_mode( $this->dbh ); 1218 1173 1219 $this->ready = true; 1174 1220 1175 1221 $this->select( $this->dbname, $this->dbh );