Closed swissspidy closed 6 years ago
Currently wondering what approach would be preferable:
download_url()
so that filters work, as you suggested.--skip-ssl-verify
flag so that you can directly control this from the command line.Maybe both?
At first glance download_url()
does a few things differently:
wp_tempnam()
to create a temporary file (vs. \WP_CLI\Utils\get_temp_dir()
)timeout
(300 vs. 600)stream
to true
when making the HTTP requestContent-MD5
header if present and abandons the file if the hashes don't match.--skip-ssl-verify
could be useful for other commands as well, but I'm sure there's a better way to make global HTTP options possible.
\WP_CLI\Utils\get_temp_dir()
obviously makes more sense than wp_tempnam()
.
Content-MD5
header verification would be handy though. Not sure about the implications of changing the other two options.
Doesn't look like any Content-MD5
is sent when download translations.
\WP_CLI\Utils\get_temp_dir()
obviously makes more sense thanwp_tempnam()
.
The caching happens later on separetly in the language pack upgrader, so I'm not sure if this would really make a huge difference.
Background: https://wordpress.slack.com/archives/C02RP4T41/p1517951327000586
I was tweaking WordPress a bit to download some language packs from another local site. Since I used self-signed certificates, I added the following lines to disable certificate verification:
This works when using the WordPress admin UI, but not when running
wp language core update
(which btw shouldn't update plugin translations, see #20). This is because since f45cec689c38411c6f05b7eef5bd8d6900d4db10 the command uses\ LanguagePackUpgrader::download_package()
(and ultimately\WP_CLI\Utils\http_request()
) to download packages (vs.download_url()
in core) and this call can't be filtered.Suggestion: Use
download_url()
so the same filters are available.We can still pass the same HTTP options, so there shouldn't be any back compat issues.