Ticket #32798: wp-db.php.patch
File wp-db.php.patch, 2.6 KB (added by , 10 years ago) |
---|
-
src/wp-includes/wp-db.php
1414 1414 * Deprecated in 3.9+ when using MySQLi. No equivalent 1415 1415 * $new_link parameter exists for mysqli_* functions. 1416 1416 */ 1417 1417 $new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true; 1418 1418 $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0; 1419 $port = null; 1420 $socket = null; 1421 $host = $this->dbhost; 1422 $port_or_socket = strstr( $host, ':' ); 1419 1423 1420 1424 if ( $this->use_mysqli ) { 1421 1425 $this->dbh = mysqli_init(); 1422 1426 1423 1427 // mysqli_real_connect doesn't support the host param including a port or socket 1424 1428 // like mysql_connect does. This duplicates how mysql_connect detects a port and/or socket file. 1425 $port = null;1426 $socket = null;1427 $host = $this->dbhost;1428 $port_or_socket = strstr( $host, ':' );1429 1429 if ( ! empty( $port_or_socket ) ) { 1430 1430 $host = substr( $host, 0, strpos( $host, ':' ) ); 1431 1431 $port_or_socket = substr( $port_or_socket, 1 ); 1432 if ( 0 !== strpos( $port_or_socket, '/' ) ) { 1433 $port = intval( $port_or_socket ); 1434 $maybe_socket = strstr( $port_or_socket, ':' ); 1435 if ( ! empty( $maybe_socket ) ) { 1436 $socket = substr( $maybe_socket, 1 ); 1437 } 1438 } else { 1439 $socket = $port_or_socket; 1432 switch(0) 1433 { 1434 case strpos( $port_or_socket, '/' ): # linux socket 1435 case strpos( $port_or_socket, '\\'): # windows pipe 1436 $socket = $port_or_socket; 1437 break; 1438 default: 1439 $port = intval( $port_or_socket ); 1440 $maybe_socket = strstr( $port_or_socket, ':' ); 1441 if ( ! empty( $maybe_socket ) ) { 1442 $socket = substr( $maybe_socket, 1 ); 1443 } 1440 1444 } 1441 1445 } 1442 1446 1443 1447 if ( WP_DEBUG ) { 1444 1448 mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags ); … … 1468 1472 $this->use_mysqli = false; 1469 1473 $this->db_connect(); 1470 1474 } 1471 1475 } 1472 1476 } else { 1477 if ( ! empty( $port_or_socket ) ) { 1478 $host = substr( $host, 0, strpos( $host, ':' ) ); 1479 $port_or_socket = substr( $port_or_socket, 1 ); 1480 if( 0===strpos( $port_or_socket, '\\' )) # windows pipe 1481 { 1482 ini_set('mysql.default_host', $host); 1483 ini_set('mysql.default_socket', $port_or_socket); 1484 } 1485 } 1486 1473 1487 if ( WP_DEBUG ) { 1474 1488 $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); 1475 1489 } else { 1476 1490 $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags ); 1477 1491 }