Skip to content

wp theme delete --all incorrectly deletes parent theme #323

@PowerKiKi

Description

@PowerKiKi

Bug Report

Describe the current, buggy behavior

I have a child theme and its parent. The child is active and the parent is correctly reported as parent:

$ wp theme list
+------------------+--------+--------+---------+
| name             | status | update | version |
+------------------+--------+--------+---------+
| north-martouf    | active | none   |         |
| siteorigin-north | parent | none   | 1.19.11 |
+------------------+--------+--------+---------+

When I run wp theme delete --all, I expect nothing to happen because the child is active, and the parent while not strictly active is required for the child to work. However the parent theme will incorrectly be deleted:

$ wp theme delete --all
Deleted 'siteorigin-north' theme.          <=== WRONG
Success: Deleted 1 of 2 themes.

Then the child won't even appear in the list (which may or may not be an unrelated issue):

$ wp theme list
+------+--------+--------+---------+
| name | status | update | version |
+------+--------+--------+---------+
+------+--------+--------+---------+

Of course this breaks the entire site until the parent is reinstalled. And it prevent us to use wp theme delete --all as a single command to clean up all our sites.

Describe how other contributors can replicate this bug

See above

Describe what you would expect as the correct outcome

I expect wp theme delete --all to preserve the active theme and its parent, so the site does not break.

Let us know what environment you are running this on

OS:	Linux 5.4.0-122-generic #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 x86_64
Shell:	/bin/bash
PHP binary:	/usr/bin/php7.4
PHP version:	7.4.30
php.ini used:	/etc/php/7.4/cli/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 15.1 Distrib 10.5.16-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
SQL modes:	
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path: ***REDACTED***
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.6.0

Provide a possible solution

Check for status active and also parent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions