[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 08:40:18 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:  4.9.1
Component:  Database      |     Version:  4.9
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+--------------------

Comment (by natacado):

 I attached a proposed patch that fixes it for me. It's my first patch for
 Wordpress, be gentle. :-) This patch depends on the fact that a socket
 path will always be absolute so we can search for `:/` in the string; the
 old code seemed to already assume this for IPv6 but didn't do so in IPv4
 code, so ... maybe there's someone out there using something like

 {{{#!php
 define('DB_HOST', 'localhost:mysql.sock');
 }}}

 And relying on some poorly-documented assumptions about current working
 directory for where `mysql.sock` would exist? I don't think it's a good
 idea to have something like this, but this patch would regress that.

 The other idea I had was to use `inet_pton` to properly search for/parse
 the IP address component from the start of the string, but that's not
 supported on Windows until PHP 5.3, so probably off-limits in Wordpress
 core.

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


More information about the wp-trac mailing list