Skip to content

Fix: prevent parent theme removal on child theme delete --all#308

Closed
ovidiul wants to merge 5 commits intowp-cli:masterfrom
thinkovi:fix/5570_fix_parent_theme_removal
Closed

Fix: prevent parent theme removal on child theme delete --all#308
ovidiul wants to merge 5 commits intowp-cli:masterfrom
thinkovi:fix/5570_fix_parent_theme_removal

Conversation

@ovidiul
Copy link
Copy Markdown

@ovidiul ovidiul commented Dec 17, 2021

This PR will try and add a fix for the issue mentioned here #325

Basically, it will first loop through the list of fetched themes and check if the actual active theme has a parent theme(is child theme) and if so, it will prevent the parent theme from being deleted unintentionally, this. unless --force is supplied.

The case when the user specifically deletes the parent theme folder with wp theme delete parent-theme is omitted since that could be intentional.

Happy to add a Behat test if this is considered. Thanks

@ovidiul ovidiul requested a review from a team as a code owner December 17, 2021 08:45
@schlessera
Copy link
Copy Markdown
Member

Thanks for the PR, @ovidiul !
Yes, a Behat test will be needed for merging this safely. Are you up for adding one?

@schlessera schlessera added bug command:theme-delete Related to 'theme delete' command labels Dec 22, 2021
@ovidiul
Copy link
Copy Markdown
Author

ovidiul commented Dec 22, 2021

Thanks for the PR, @ovidiul ! Yes, a Behat test will be needed for merging this safely. Are you up for adding one?

Yes, happy to add a Behat test once I figure that one out.

I saw some PHPCS issues and a commented line which should not have been disabled, so I've updated the PR with those changes. Thanks!

@ovidiul
Copy link
Copy Markdown
Author

ovidiul commented Dec 24, 2021

@schlessera I've added 2 Behat tests for when the child theme is activated.

Let me know if you see further changes needed. Thanks

Copy link
Copy Markdown
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ovidiul Thanks for the PR!
I've tested the PR and I've encountered the following scenario:

When a child theme is active, WordPress doesn't allow deletion of the parent theme unless the theme is switched.
But WP-CLI at the moment allows deletion of the parent theme even when the child theme is active. Can you make that change? The rest looks good!

@ovidiul
Copy link
Copy Markdown
Author

ovidiul commented Feb 11, 2022

👋 @Sidsector9 change is now in place.

Thank you.

@danielbachhuber
Copy link
Copy Markdown
Member

Thanks for your work on this, @ovidiul !

Finishing it up with #324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:theme-delete Related to 'theme delete' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants