Ticket #27703: 27703.diff
File 27703.diff, 4.4 KB (added by , 10 years ago) |
---|
-
src/wp-includes/wp-db.php
579 579 $this->show_errors(); 580 580 581 581 /* Use ext/mysqli if it exists and: 582 * - WP_USE_EXT_MYSQL is defined as false, or582 * - USE_EXT_MYSQL is defined as false, or 583 583 * - We are a development version of WordPress, or 584 584 * - We are running PHP 5.5 or greater, or 585 585 * - ext/mysql is not loaded. 586 586 */ 587 587 if ( function_exists( 'mysqli_connect' ) ) { 588 if ( defined( ' WP_USE_EXT_MYSQL' ) ) {589 $this->use_mysqli = ! WP_USE_EXT_MYSQL;588 if ( defined( 'USE_EXT_MYSQL' ) ) { 589 $this->use_mysqli = ! USE_EXT_MYSQL; 590 590 } elseif ( version_compare( phpversion(), '5.5', '>=' ) || ! function_exists( 'mysql_connect' ) ) { 591 591 $this->use_mysqli = true; 592 592 } elseif ( false !== strpos( $GLOBALS['wp_version'], '-' ) ) { … … 1299 1299 /** 1300 1300 * Connect to and select database. 1301 1301 * 1302 * If $allow_bail is false, the lack of database connection will need1303 * to be handled manually.1304 *1305 1302 * @since 3.0.0 1306 * @since 3.9.0 $allow_bail parameter added.1307 1303 * 1308 * @param bool $allow_bail Optional. Allows the function to bail. Default true. 1304 * @param bool $allow_bail Optional. Allows the function to bail, default true. If this is set 1305 * to false, you will need to handle the lack of database connection 1306 * manually. Available since 3.9.0. 1307 * 1309 1308 * @return bool True with a successful connection, false on failure. 1310 1309 */ 1311 1310 function db_connect( $allow_bail = true ) { … … 1349 1348 1350 1349 /* It's possible ext/mysqli is misconfigured. Fall back to ext/mysql if: 1351 1350 * - We haven't previously connected, and 1352 * - WP_USE_EXT_MYSQL isn't set to false, and1351 * - USE_EXT_MYSQL isn't set to false, and 1353 1352 * - ext/mysql is loaded. 1354 1353 */ 1355 1354 $attempt_fallback = true; 1356 1355 1357 1356 if ( $this->has_connected ) { 1358 1357 $attempt_fallback = false; 1359 } else if ( defined( ' WP_USE_EXT_MYSQL' ) && ! WP_USE_EXT_MYSQL ) {1358 } else if ( defined( 'USE_EXT_MYSQL' ) && ! USE_EXT_MYSQL ) { 1360 1359 $attempt_fallback = false; 1361 1360 } else if ( ! function_exists( 'mysql_connect' ) ) { 1362 1361 $attempt_fallback = false; … … 1415 1414 * If this function is unable to reconnect, it will forcibly die, or if after the 1416 1415 * the template_redirect hook has been fired, return false instead. 1417 1416 * 1418 * If $allow_bail is false, the lack of database connection will need1419 * to be handled manually.1420 *1421 1417 * @since 3.9.0 1422 1418 * 1423 * @param bool $allow_bail Optional. Allows the function to bail. Default true. 1419 * @param bool $allow_bail Optional. Allows the function to bail, default true. If this is set 1420 * to false, you will need to handle the lack of database connection 1421 * manually. 1422 * 1424 1423 * @return bool True if the connection is up. 1425 1424 */ 1426 1425 function check_connection( $allow_bail = true ) { … … 1599 1598 } 1600 1599 1601 1600 /** 1602 * Internal function to perform the mysql_query () call.1601 * Internal function to perform the mysql_query call 1603 1602 * 1604 1603 * @since 3.9.0 1605 1604 * 1606 1605 * @access private 1607 1606 * @see wpdb::query() 1608 1607 * 1609 * @param string $query The query to run .1608 * @param string $query The query to run 1610 1609 */ 1611 1610 private function _do_query( $query ) { 1612 1611 if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { … … 1963 1962 1964 1963 if ( $this->use_mysqli ) { 1965 1964 for ( $i = 0; $i < @mysqli_num_fields( $this->result ); $i++ ) { 1966 $this->col_info[ $i ] = @mysqli_fetch_field( $this->result );1965 $this->col_info[ $i ] = @mysqli_fetch_field( $this->result, $i ); 1967 1966 } 1968 1967 } else { 1969 1968 for ( $i = 0; $i < @mysql_num_fields( $this->result ); $i++ ) { … … 2137 2136 * 2138 2137 * @since 2.7.0 2139 2138 * 2139 * @param bool $full Optional. Flag to provide the full version string, default false. Available since 3.9.0. 2140 * 2140 2141 * @return false|string false on failure, version number on success 2141 2142 */ 2142 function db_version( ) {2143 function db_version( $full = false ) { 2143 2144 if ( $this->use_mysqli ) { 2144 2145 $server_info = mysqli_get_server_info( $this->dbh ); 2145 2146 } else { 2146 2147 $server_info = mysql_get_server_info( $this->dbh ); 2147 2148 } 2148 return preg_replace( '/[^0-9.].*/', '', $server_info ); 2149 2150 if ( $full ) { 2151 return $server_info; 2152 } else { 2153 return preg_replace( '/[^0-9.].*/', '', $server_info ); 2154 } 2149 2155 } 2150 2156 }