Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#10045 closed defect (bug) (fixed)

fsockopen() fails connecting to localhost when the server contains a ipv6 hosts entry

Reported by: dd32 Owned by: dd32
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8
Component: HTTP API Keywords: has-patch early commit
Focuses: Cc:


fsockopen() fails connecting to localhost when the server contains a ipv6 hosts entry, While this only happens with certain versions of PHP (And has been a bug for quite a long time) i feel its probably best to work around it.

See patch which sets it to connect to in these cases.

(Note, This mainly affects those who are running test blogs on http://localhost/ and cron kicks in)

Attachments (1)

10045.diff (698 bytes) - added by dd32 12 years ago.

Download all attachments as: .zip

Change History (8)

12 years ago

#1 @Denis-de-Bernardy
12 years ago

this can have weird side effects with cron when behind a load balancer.

#2 @Denis-de-Bernardy
12 years ago

Using 127.0.1 *might* have side effects that is. Expanding on the above comment for reference, I had the following issue when connecting to mysql on my own server.

Until I switched to using two servers and an NDB cluster, I'd connect to with MySQL. After the switch, I reverted this back to using localhost. Because, localhost would allow to configure permissions in mysql as user / localhost, whereas couldn't be configured as such -- it had to be user / real IP. MySQL would convert to the server's real IP.

Anyway, felt like pointing this out. What would be the most straightforward (step by step) means to test, so I can give it a shot?

#3 @dd32
12 years ago

There are side effects, Some security software blocks if attempts are made to connect to the loopback instead of wan interface.

This doesnt affect most users, it only affects people who run a blog on the localhost, that is, have the site url set to localhost.

On a production server, WordPress doesnt connect to 'localhost' instead it connected to 'real.fqdn.whatever' which resolves to which has no problem.

*This doesnt affect those on a load balancer. This doesnt affect those running live servers, This affects nearly no end users. It only affects developers*

Its common for desktop setups to include a IPv6 loopback definition in the hosts file, Eg, Vista:       localhost
::1             localhost

If someones running a blog on localhost, mainly for dev work, and is using fsockopen HTTP transport (Which will be 99.9% of us now that #9998 has changed the order) then there'll be Cron issues.

Previously most installs didn't use the fsockopen transport, all the other transports dont have this problem with the loopback dns.

I have a feeling that code very similar to this existed in the pre-http-api days, to solve this exact problem.

This can wait until early in 2.9 if need be, It'll probably be needed when everyone starts complaining in about 48 hours.. ;)

#4 @peaceablewhale
12 years ago

What versions of PHP are affected by the bug?

#5 @dd32
12 years ago

  • Keywords early commit 2nd-opinion added
  • Milestone changed from 2.8 to 2.9

What versions of PHP are affected by the bug?

No idea.. I dont have the original bug i saw handy. Theres similar ones though, ie. http://bugs.php.net/bug.php?id=40279

I could've sworn there was similar code to this in the old cron code.. But i cant seem to see any of it there.

#6 @Denis-de-Bernardy
12 years ago

  • Keywords 2nd-opinion removed

let's get it in then

#7 @markjaquith
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11759]) Force IPv4 ( when connecting to localhost, as many dev environments are not set up to serve on IPv6 (::1). props dd32. fixes #10045

Note: See TracTickets for help on using tickets.