Make WordPress Core

Ticket #32798: wp-db.php.patch

File wp-db.php.patch, 2.6 KB (added by bogdan.ionescu, 10 years ago)

wp-db.php diff from revision 32925

  • src/wp-includes/wp-db.php

     
    14141414                 * Deprecated in 3.9+ when using MySQLi. No equivalent
    14151415                 * $new_link parameter exists for mysqli_* functions.
    14161416                 */
    14171417                $new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true;
    14181418                $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, ':' );
    14191423
    14201424                if ( $this->use_mysqli ) {
    14211425                        $this->dbh = mysqli_init();
    14221426
    14231427                        // mysqli_real_connect doesn't support the host param including a port or socket
    14241428                        // 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, ':' );
    14291429                        if ( ! empty( $port_or_socket ) ) {
    14301430                                $host = substr( $host, 0, strpos( $host, ':' ) );
    14311431                                $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                                                }
    14401444                                }
    14411445                        }
    14421446
    14431447                        if ( WP_DEBUG ) {
    14441448                                mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
     
    14681472                                        $this->use_mysqli = false;
    14691473                                        $this->db_connect();
    14701474                                }
    14711475                        }
    14721476                } 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                       
    14731487                        if ( WP_DEBUG ) {
    14741488                                $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
    14751489                        } else {
    14761490                                $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
    14771491                        }