Ticket #21663: 21663.15.diff
File 21663.15.diff, 1.9 KB (added by , 11 years ago) |
---|
-
src/wp-includes/wp-db.php
569 569 $this->show_errors(); 570 570 571 571 /* Use ext/mysqli if it exists and: 572 * - USE_EXT_MYSQL is defined as false, or 572 573 * - We are a development version of WordPress, or 573 574 * - We are running PHP 5.5 or greater, or 574 575 * - ext/mysql is not loaded. 575 576 */ 576 577 if ( function_exists( 'mysqli_connect' ) ) { 577 if ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) { 578 if ( defined( 'USE_EXT_MYSQL' ) ) { 579 $this->use_mysqli = ! USE_EXT_MYSQL; 580 } elseif ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) { 578 581 $this->use_mysqli = true; 579 582 } elseif ( false !== strpos( $GLOBALS['wp_version'], '-' ) ) { 580 583 $this->use_mysqli = true; … … 1011 1014 * @return string escaped 1012 1015 */ 1013 1016 function _real_escape( $string ) { 1014 if ( $this->dbh ) {1015 if ( $this->use_mysqli ) {1017 if ( $this->dbh || ( $this->use_mysqli && ! $this->dbh->connect_errno ) ) { 1018 if ( $this->use_mysqli && ! $this->dbh->connect_errno ) { 1016 1019 return mysqli_real_escape_string( $this->dbh, $string ); 1017 1020 } else { 1018 1021 return mysql_real_escape_string( $string, $this->dbh ); … … 1335 1338 } 1336 1339 } 1337 1340 1338 if ( ! $this->dbh&& $allow_bail ) {1341 if ( ( ! $this->dbh || ( $this->use_mysqli && $this->dbh->connect_errno ) ) && $allow_bail ) { 1339 1342 wp_load_translations_early(); 1340 1343 1341 1344 // Load custom DB error template, if present. … … 1356 1359 " ), htmlspecialchars( $this->dbhost, ENT_QUOTES ) ), 'db_connect_fail' ); 1357 1360 1358 1361 return false; 1359 } else if ( $this->dbh ) {1362 } else if ( $this->dbh || ( $this->use_mysqli && ! $this->dbh->connect_errno ) ) { 1360 1363 $this->set_charset( $this->dbh ); 1361 1364 $this->set_sql_mode(); 1362 1365 $this->ready = true;