When --version=x.y.z is supplied to theme update the theme is first deleted, then installed. This is disastrous if WP cannot find the specified version for a theme or if a user supplies an incorrect version as the theme has now been deleted from the site.
Describe how other contributors can replicate this bug
wp --debug theme update twentynineteen --version=7.2
# Reports Error: Can't find the requested theme's version 7.2 in the WordPress.org theme repository (HTTP code 404).
wp --debug theme update twentynineteen --version=7.2
# Reports Warning: The 'twentynineteen' theme could not be found.
wp theme list
# twentynineteen now omitted from list
Describe what you would expect as the correct outcome
Theme update fails safely and does not remove the existing theme.
OS: Linux 3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020 x86_64
Shell: /bin/bash
PHP binary: /.socket/php/usr/bin/php
PHP version: 7.4.11
php.ini used: /etc/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.3.22-MariaDB, for Linux (x86_64) using readline 5.1
SQL modes: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
WP-CLI root dir: /var/www/wp-cli
WP-CLI vendor dir: /var/www/wp-cli/vendor
WP_CLI phar path:
WP-CLI packages dir:
WP-CLI global config: /home/benchmark-user/.wp-cli/config.yml
WP-CLI project config:
WP-CLI version: 2.5.0-alpha
Provide a possible solution
Rename theme, apply update, then delete or rename directory depending upon install().
Bug Report
Describe the current, buggy behavior
When
--version=x.y.z
is supplied totheme update
the theme is first deleted, then installed. This is disastrous if WP cannot find the specified version for a theme or if a user supplies an incorrect version as the theme has now been deleted from the site.Problem code
Reference: Theme_Command.php 658-668
Describe how other contributors can replicate this bug
Describe what you would expect as the correct outcome Theme update fails safely and does not remove the existing theme.
Provide a possible solution Rename theme, apply update, then delete or rename directory depending upon
install()
.