Opened 10 years ago
Closed 6 years ago
#32798 closed enhancement (maybelater)
Add support for mysql named pipe (windows os)
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Database | Keywords: | has-patch needs-refresh |
Focuses: | performance | Cc: |
Description
This patch allows the connection via pipe into the windows operating system.
Configuration needed:
MySQL 5.6 file: my.ini
[mysqld] # # ... other settings here ... # skip-networking enable-named-pipe socket="mysql56.pipe" [client] # # ... other settings here ... # pipe socket="mysql56.pipe"
Wordpress file: wp-config.php
<?php # # ... other settings here ... # /** The name of the database for WordPress */ define('DB_NAME', 'wp_demo1'); /** MySQL database username */ define('DB_USER', 'wp_demo1'); /** MySQL database password */ define('DB_PASSWORD', 'pa$$w0rd'); /** MySQL hostname */ define('DB_HOST', '.:\\\\.\\pipe\\mysql56.pipe'); # syntax = ".:\\.\pipe\name.pipe" /** MySQLi extension (optional) */ #define('WP_USE_EXT_MYSQL', false); # for mysqli set to false /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', 'utf8_general_ci');
Wordpress patch: wp-db.php
-
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 }
Attachments (3)
Change History (7)
#1
@
10 years ago
- Focuses accessibility performance added
- Keywords has-patch added
- Severity changed from normal to critical
#2
@
10 years ago
- Severity changed from critical to normal
- Type changed from defect (bug) to enhancement
- Version 4.2.2 deleted
#4
@
6 years ago
- Keywords needs-refresh added
- Resolution set to maybelater
- Status changed from new to closed
This isn't something that we've seen much interest in over the years.
If someone wants to make a new patch, along with unit tests, I'm happy for this ticket to be reopened. Until then, I'm going to close it.
Note: See
TracTickets for help on using
tickets.
wp-db.php diff from revision 32925