[wp-trac] [WordPress Trac] #41722: wpdb::db_connect() does not connect to IPv6 address of mysql server

WordPress Trac noreply at wordpress.org
Mon Aug 28 15:55:55 UTC 2017


#41722: wpdb::db_connect() does not connect to IPv6 address of mysql server
-------------------------------------+--------------------
 Reporter:  fierevere                |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  4.9
Component:  Database                 |     Version:  4.8.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+--------------------

Comment (by birgire):

 To be able to parse

 {{{
 'localhost:/tmp/mysql.sock'
 }}}

 we could adjust the regex to:

 {{{
 if ( substr_count( $host, ':' ) > 1 ) {
         $pattern = '#^(?:\[)?(?<host>[0-9a-
 fA-F:]+)(?:\]:(?<port>[\d]+))?(?::(?<socket>.+))?#';
         $is_ipv6 = true;
 } else {
         // We seem to be dealing with an IPv4 address.
         $pattern =
 '#^(?:\[)?(?<host>[^:^/]+)(?::(?<port>[\d]+))?(?::(?<socket>.+))?#';
 }
 }}}

 Then the above tests runs fine with:

 {{{
 OK (1 test, 9 assertions)
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41722#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list