#38291 closed defect (bug) (invalid)
gethostbyname() at wp-includes/http.php don´t work if host is ipv6 configured
Reported by: | lofesa | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.6.1 |
Component: | HTTP API | Keywords: | close |
Focuses: | Cc: |
Description
I allways get the message "Download failed. A valid URL was not provided" when I try to reinstall wordpress, update translations, plugins or install news plugins. I can do it manually.
Searched these text message in code files at github, then added a number for each for differentiate and find the message becomes from wp-includes/class-http.php at line 264.
I put these code into the "if" condition
file_put_contents('path(to/the/file/variable.txt',$url,FILE_APPEND);
file_put_contents('path(to/the/file/variable.txt',$arrURL,FILE_APPEND);
and allways the variables are empty...but if I put the catch code before the if condition get these values
As you can see some url´s have loss the ":\/\/" between the http(s) and the url, I don´t know if this is the expected behaviour, but why the varibles are lossing their values between lines 262 and 264?
I have tried to update/install flushing all caches, disabling all plugings, disabling child theme..... and allways get the same message "Upgrading from..URL Donwload failed. A valid URL was not provided"
P.S. Sorry for my bad english.
Change History (11)
#2
in reply to:
↑ 1
@
8 years ago
- Keywords reporter-feedback added
Hi @swissspidy
Sorry for the delay, yesterday was a non-working day here.
I don´t mind is related to [38727]. In a plus elaborated code to catch the values from $url and $arrURL with:
file_put_contents('/path/to/variable.txt','url: '.$url."\n",FILE_APPEND);
file_put_contents('/path/to/variable.txt','arrURL:'.json_encode($arrURL)."\n",FILE_APPEND);
get these results:
url: http://version.wpbakery.com/?1476339348
arrURL: {"scheme":"http","host":"version.wpbakery.com","path":"\/","query":"1476339348"}
url: https://api.wordpress.org/plugins/update-check/1.1/
arrURL: {"scheme":"https","host":"api.wordpress.org","path":"\/plugins\/update-check\/1.1\/"}
url: http://version.wpbakery.com/?1476339348
arrURL: {"scheme":"http","host":"version.wpbakery.com","path":"\/","query":"1476339348"}
url: https://api.wordpress.org/plugins/update-check/1.1/
arrURL: {"scheme":"https","host":"api.wordpress.org","path":"\/plugins\/update-check\/1.1\/"}
url: http://version.wpbakery.com/?1476339348
arrURL: {"scheme":"http","host":"version.wpbakery.com","path":"\/","query":"1476339348"}
url: https://api.wordpress.org/themes/update-check/1.1/
arrURL: {"scheme":"https","host":"api.wordpress.org","path":"\/themes\/update-check\/1.1\/"}
url: https://api.wordpress.org/core/version-check/1.7/?version=4.6.1&php=7.0.11&locale=en_US&mysql=5.5.5&local_package=&blogs=1&users=2&multisite_enabled=0&initial_db_version=33056
arrURL: {"scheme":"https","host":"api.wordpress.org","path":"\/core\/version-check\/1.7\/","query":"version=4.6.1&php=7.0.11&locale=en_US&mysql=5.5.5&local_package=&blogs=1&users=2&multisite_enabled=0&initial_db_version=33056"}
url: https://api.wordpress.org/core/checksums/1.0/?version=4.6.1&locale=en_US
arrURL: {"scheme":"https","host":"api.wordpress.org","path":"\/core\/checksums\/1.0\/","query":"version=4.6.1&locale=en_US"}
url:
arrURL: {"path":""}
As you can see, at some point the $url and $arrURL are empty....
And I can´t see the download url (in this case https://downloads.wordpress.org/release/wordpress-4.6.1-no-content.zip) that I see in the error message
Along this day I will try to use the latest nightly build and tell you the result
Thx for your help.
Replying to swissspidy:
Hey there,
Welcome to WordPress Trac!
This might already be resolved by [38727] (see #38070). Previously: #37733.
Can you test if the issue still exists when running the latest nightly build?
#3
@
8 years ago
Hi again @swissspidy
I downloaded the master.zip from github and upload files.... I can´t login to wordpress, get these error:
2016/10/13 09:05:50 [error] 20910#20910: *100101 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to a member function add_filter() on array in /path/to/wp-includes/plugin.php:111
Stack trace:
#0 /path/to/wp-includes/plugin.php(399): add_filter('template_redire...', 'rest_output_lin...', 11, 0)
#1 /path/to/wp-includes/default-filters.php(221): add_action('template_redire...', 'rest_output_lin...', 11, 0)
#2 /path/to/wp-settings.php(113): require('/var/www/html/i...')
#3 /path/to/wp-config.php(102): require_once('/var/www/html/i...')
#4 /path/to/wp-load.php(39): require_once('/var/www/html/i...')
#5 /path/to/wp-admin/admin.php(31): require_once('/var/www/html/i...')
#6 /path/to/wp-admin/index.php(10): require_once('/var/www/html/i...')
#7 {main}
thrown in /path/to/wp-includes/plugin.php on line 111" while reading response header from upstream, client:[ IP ], server: [host name], request: "GET /wp-admin/ HTTP/1.1", upstream: "fastcgi://unix:[path/to/sockect]", host: "[host name]"
thus I can´t try with the latest nightly build.
Thx you in advance.
#5
@
8 years ago
Hi again @swissspidy
I get more info from this issue:
Parse url: https://downloads.wordpress.org/release/wordpress-4.6.1-no-content.zip
Parse args: {"method":"GET","timeout":300,"stream":true,"filename":"\/tmp\/wordpress-4.6.1-no-content-gW2H0r.tmp","reject_unsafe_urls":true}
url:
arrURL: {"path":""}
Trace :#0 /var/www/html/intersindical/wp-includes/class-http.php(602): WP_Http->request(false, Array)
#1 /var/www/html/intersindical/wp-includes/http.php(70): WP_Http->get('https://downloa...', Array)
#2 /var/www/html/intersindical/wp-admin/includes/file.php(502): wp_safe_remote_get('https://downloa...', Array)
#3 /var/www/html/intersindical/wp-admin/includes/class-wp-upgrader.php(277): download_url('https://downloa...')
#4 /var/www/html/intersindical/wp-admin/includes/class-core-upgrader.php(122): WP_Upgrader->download_package('https://downloa...')
#5 /var/www/html/intersindical/wp-admin/update-core.php(490): Core_Upgrader->upgrade(Object(stdClass), Array)
#6 /var/www/html/intersindical/wp-admin/update-core.php(643): do_core_upgrade(true)
#7 {main}
All the url´s related to downloads are emptied in a point between http.php and class-http.php, all the others url´s are ok.
I tried to force "reject_unsafe_urls":false, but not luck, the requested url continue to be emptied. How I can debug what happen whit these url´s?:
#6
@
8 years ago
- Component changed from Upgrade/Install to General
- Summary changed from Can´t upgrade nor install plugins, wordpress or translations to gethostbyname() at wp-includes/http.php don´t work if host is ipv6 configured
Hi again @swissspidy
I solved the issue. The fail thing was that gethostbyname($host) at line 543 on file wp-includes/http.php don´t convert names in ip address and get the ip 0.0.0.0 in a mixed ipv4-ipv6 configured host and resolving same host names to ipv4 and ipv6.
I leave off all the ipv6 config in host and dns and leave the host in only ipv4, then updates and install they worked.
Change the ticket to reflect that and leave it open to devs review.
#7
@
8 years ago
- Component changed from General to HTTP API
Hi @lofesa,
Can you provide more details on how the host is configured with IPv4 / IPv6? I have multiple IPv6 mixed mode hosts and the only issues i've had with similar outcomes is when it's been configured incorrectly (personal experience there).
As WordPress.org doesn't have any IPv6 connectivity at present, there should be no IPv6 addresses in play here, and your DNS server shouldn't be able to resolve anything - but it should be falling back to IPv4 and 0.0.0.0
shouldn't be returned here at all.
Can you perhaps try on the command line and see what dig +short api.wordpress.org
and dig -6 +short api.wordpress.org
return?
The other thing to check would be if changing $ip = gethostbyname( $host );
to $ip = gethostbyname( $host . '.' );
works for you.
#8
@
8 years ago
Hi @dd32
Sorry for the delay.
the ipv6 config files are:
/etc/sysconfig/network-scripts/ifcfg-eth0
TYPE="Ethernet"
BOOTPROTO=none
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
NAME="eth0"
#UUID=""
DEVICE="eth0"
ONBOOT="yes"
IPADDR= adress
PREFIX=24
GATEWAY=adress
#DNS1=adress
#DNS2=adress
PEERDNS=no
#IPV&-config
IPV6INIT="yes"
#IPV6_PEERDNS=yes
#IPV6_AUTOCONF="yes"
IPV6_PEERROUTES=yes
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6ADDR="adrees/64"
IPV6_DEFAULTGW="fe80::1%eth0"
IPV6_DEFAULTDEV=eth0
NM_CONTROLLED=no
# Generated by NetworkManager
options inet6
options timeout 1
search domain
nameserver 8.8.8.8
nameserver ipv6 address
nameserver ipv6 address
nameserver address
nameserver address
nameserver address
nameserver address
nameserver ipv6 address
nameserver address
nameserver address
nameserver address
nameserver address
nameserver address
nameserver address
nameserver ipv6 address
nameserver ipv6 address
nameserver ipv6 address
nameserver ipv6 address
options rotate
coment the lines, in resolv.conf, relatives to ipv6 do the work.
need more info?
We received messages that a plugin need to be updated or a translation too, but the download fails.
I disabled all ipv6 stuff (dns AAAA records, resolv.conf and device config) thus they worked, then re-enable all the ipv6 and comment the lines in resolv.conf and worked again.
Whit this script I can reproduce the issue:
<?php
$host = 'download.wordpress.org';
$host1 = 'downloads.wordpress.org';
$ip = gethostbyname($host);
$ip1 = gethostbyname($host1);
$info = gethostbynamel($host1);
echo $host."\n";
echo $ip."\n";
echo $host1."\n";
echo $ip1;
echo json_encode($info);
?>
download.wordpress.org always returns 66.155.40.250
downloads.wordpress.org returns
66.155.40.186["66.155.40.188","66.155.40.187","66.155.40.186","66.155.40.189"] or
0.0.0.0["0.0.0.0","0.0.0.0","0.0.0.0","0.0.0.0"] if the line options inet6 is uncommented in resolv.conf.
the option you suggest don´t do the trick.
#9
follow-up:
↓ 10
@
8 years ago
- Keywords close added
search domain
Assuming domain
is your actual domain, and you have a wildcard DNS in place on that domain, I think that's the source of your issue.
I kind-of duplicated it with that configuration (for reference, I use search .
normally) with ping6 api.wordpress.org
which should show an unknown host
error but will probably reference your local IPv6 address instead.
With the info you've given there, it's most definitely some kind of failure in the local DNS configuration, if enabling ipv6 causes dns queries to fail, there's not much we can do about it in WordPress.
#10
in reply to:
↑ 9
@
8 years ago
- Resolution set to invalid
- Status changed from new to closed
Hi @dd32
I tried to comment these line (search domain) and put "search ." too, result are the same, when "options inet6" is uncommented.
In other hand, I tried to use gethostbyname6 and gethostbynamel6, referenced at https://forums.phpfreaks.com/topic/157824-gethostbyname-for-ipv6/ with $try_a to true and it work, no matter if "options inet6" is present or not.
I don´t have any other dns configuration other than /etc/resolv.conf
Perhaps test for an A dns record is needed?
Replying to dd32:
search domain
Assuming
domain
is your actual domain, and you have a wildcard DNS in place on that domain, I think that's the source of your issue.
I kind-of duplicated it with that configuration (for reference, I use
search .
normally) withping6 api.wordpress.org
which should show anunknown host
error but will probably reference your local IPv6 address instead.
With the info you've given there, it's most definitely some kind of failure in the local DNS configuration, if enabling ipv6 causes dns queries to fail, there's not much we can do about it in WordPress.
Hey there,
Welcome to WordPress Trac!
This might already be resolved by [38727] (see #38070). Previously: #37733.
Can you test if the issue still exists when running the latest nightly build?