@@ -120,6 +120,9 @@ public function check_update( $_, $assoc_args ) {
120
120
* [--insecure]
121
121
* : Retry download without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
122
122
*
123
+ * [--extract]
124
+ * : Whether to extract the downloaded file. Defaults to true.
125
+ *
123
126
* ## EXAMPLES
124
127
*
125
128
* $ wp core download --locale=nl_NL
@@ -130,7 +133,6 @@ public function check_update( $_, $assoc_args ) {
130
133
* @when before_wp_load
131
134
*/
132
135
public function download ( $ args , $ assoc_args ) {
133
-
134
136
$ download_dir = ! empty ( $ assoc_args ['path ' ] )
135
137
? ( rtrim ( $ assoc_args ['path ' ], '/ \\' ) . '/ ' )
136
138
: ABSPATH ;
@@ -239,14 +241,19 @@ public function download( $args, $assoc_args ) {
239
241
}
240
242
241
243
$ bad_cache = false ;
244
+ $ extract = (bool ) Utils \get_flag_value ( $ assoc_args , 'extract ' , true );
245
+
242
246
if ( $ cache_file ) {
243
247
WP_CLI ::log ( "Using cached file ' {$ cache_file }'... " );
244
248
$ 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
+ }
250
257
}
251
258
}
252
259
@@ -296,11 +303,12 @@ function () use ( $temp ) {
296
303
}
297
304
298
305
$ 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
+ }
304
312
}
305
313
306
314
// Do not use the cache for nightly builds or for downloaded URLs
0 commit comments