@@ -120,6 +120,9 @@ public function check_update( $_, $assoc_args ) {
120120 * [--insecure]
121121 * : Retry download without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
122122 *
123+ * [--extract]
124+ * : Whether to extract the downloaded file. Defaults to true.
125+ *
123126 * ## EXAMPLES
124127 *
125128 * $ wp core download --locale=nl_NL
@@ -130,7 +133,6 @@ public function check_update( $_, $assoc_args ) {
130133 * @when before_wp_load
131134 */
132135 public function download ( $ args , $ assoc_args ) {
133-
134136 $ download_dir = ! empty ( $ assoc_args ['path ' ] )
135137 ? ( rtrim ( $ assoc_args ['path ' ], '/ \\' ) . '/ ' )
136138 : ABSPATH ;
@@ -239,14 +241,19 @@ public function download( $args, $assoc_args ) {
239241 }
240242
241243 $ bad_cache = false ;
244+ $ extract = (bool ) Utils \get_flag_value ( $ assoc_args , 'extract ' , true );
245+
242246 if ( $ cache_file ) {
243247 WP_CLI ::log ( "Using cached file ' {$ cache_file }'... " );
244248 $ skip_content_cache_file = $ skip_content ? self ::strip_content_dir ( $ cache_file ) : null ;
245- try {
246- Extractor::extract ( $ skip_content_cache_file ?: $ cache_file , $ download_dir );
247- } catch ( Exception $ exception ) {
248- WP_CLI ::warning ( 'Extraction failed, downloading a new copy... ' );
249- $ bad_cache = true ;
249+ if ( $ extract ) {
250+ try {
251+ Extractor::extract ( $ skip_content_cache_file ?: $ cache_file , $ download_dir );
252+
253+ } catch ( Exception $ exception ) {
254+ WP_CLI ::warning ( 'Extraction failed, downloading a new copy... ' );
255+ $ bad_cache = true ;
256+ }
250257 }
251258 }
252259
@@ -296,11 +303,12 @@ function () use ( $temp ) {
296303 }
297304
298305 $ skip_content_temp = $ skip_content ? self ::strip_content_dir ( $ temp ) : null ;
299-
300- try {
301- Extractor::extract ( $ skip_content_temp ?: $ temp , $ download_dir );
302- } catch ( Exception $ exception ) {
303- WP_CLI ::error ( "Couldn't extract WordPress archive. {$ exception ->getMessage ()}" );
306+ if ( $ extract ) {
307+ try {
308+ Extractor::extract ( $ skip_content_temp ?: $ temp , $ download_dir );
309+ } catch ( Exception $ exception ) {
310+ WP_CLI ::error ( "Couldn't extract WordPress archive. {$ exception ->getMessage ()}" );
311+ }
304312 }
305313
306314 // Do not use the cache for nightly builds or for downloaded URLs
0 commit comments