[wp-trac] [WordPress Trac] #42634: Regression: Wordpress 4.9 does not parse DB_HOST socket paths with colons correctly

WordPress Trac noreply at wordpress.org
Mon Nov 20 05:23:50 UTC 2017


#42634: Regression: Wordpress 4.9 does not parse DB_HOST socket paths with colons
correctly
--------------------------+-----------------------------
 Reporter:  natacado      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Database      |    Version:  4.9
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The new `parse_db_host code` introduced in Wordpress 4.9 to parse IPv6
 database host information has caused a regression: if connecting to a
 database using a UNIX socket and the socket path contains a colon, it
 fails to parse because it assumes it's an IPv6 address by virtue of having
 more than one colon.

 This is common for users of Google Cloud SQL using the cloud_sql_proxy; it
 creates sockets with paths of the form
 `/cloudsql/$PROJECT:$REGION:$DATABASE`
 (https://cloud.google.com/sql/docs/mysql/connect-external-app - see step
 7, "UNIX SOCKETS" tab.)

 You can reproduce this by adding an additional unit test:


 {{{
 Index: tests/phpunit/tests/db.php
 ===================================================================
 --- tests/phpunit/tests/db.php  (revision 42204)
 +++ tests/phpunit/tests/db.php  (working copy)
 @@ -1559,6 +1559,14 @@
                                 false,
                         ),
                         array(
 +                               ':/tmp/mysql:with_colon.sock',
 +                               false,
 +                               '',
 +                               null,
 +                               '/tmp/mysql:with_colon.sock',
 +                               false,
 +                       ),
 +                       array(
                                 '127.0.0.1',
                                 false,
                                 '127.0.0.1',
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42634>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list