Add Support for Retry in WP CLI Core Download Command
Description
This PR supports a retry mechanism in the WP CLI core download command. With the addition of --retry=
Features Added:
- The
--retry=<retry>flag allows users to specify the number of retry attempts in case of download failure. The default value is set to 0. - The
--retry-delay=<delay>flag allows users to specify the delay (in seconds) between retry attempts. The default delay is set to 5 seconds.
Usage Examples:
-
wp core download --retry=5 --retry-delay=10- Downloads WordPress core with 5 retry attempts and a delay of 10 seconds between each attempt. -
wp core download --retry=3- Downloads WordPress core with 3 retry attempts using the default delay of 5 seconds between each attempt.
Issue: https://github.com/wp-cli/core-command/issues/155
We do have a recurring need for retries in several places, so I think it would make sense to add the capability for retries to Utils\http_request(). It has an $options argument that we can extend to support retry semantics.
The only thing to keep aware of is that it already contains a retry mechanism for retrying failed verified requests in an unverified way. The logic will probably end up looking more complex that it should because of that.