diff --git a/features/plugin-activate.feature b/features/plugin-activate.feature index a2c32c2a..ed334553 100644 --- a/features/plugin-activate.feature +++ b/features/plugin-activate.feature @@ -115,3 +115,13 @@ Feature: Activate WordPress plugins Success: Activated 1 of 1 plugins. """ And the return code should be 0 + + Scenario: Excluding a missing plugin should not throw an error + Given a WP install + And I run `wp plugin activate --all --exclude=missing-plugin` + Then STDERR should be empty + And STDOUT should contain: + """ + Success: + """ + And the return code should be 0 diff --git a/features/plugin-deactivate.feature b/features/plugin-deactivate.feature index 5cbd8e0d..7a679110 100644 --- a/features/plugin-deactivate.feature +++ b/features/plugin-deactivate.feature @@ -94,3 +94,13 @@ Feature: Deactivate WordPress plugins Error: Please specify one or more plugins, or use --all. """ And STDOUT should be empty + + Scenario: Excluding a missing plugin should not throw an error + Given a WP install + And I run `wp plugin deactivate --all --exclude=missing-plugin` + Then STDERR should be empty + And STDOUT should contain: + """ + Success: + """ + And the return code should be 0 diff --git a/features/plugin-delete.feature b/features/plugin-delete.feature index 3ec4c472..a0cdb822 100644 --- a/features/plugin-delete.feature +++ b/features/plugin-delete.feature @@ -47,3 +47,13 @@ Feature: Delete WordPress plugins Success: No plugins deleted. """ And the return code should be 0 + + Scenario: Excluding a missing plugin should not throw an error + Given a WP install + And I run `wp plugin delete --all --exclude=missing-plugin` + Then STDERR should be empty + And STDOUT should contain: + """ + Success: + """ + And the return code should be 0 diff --git a/features/plugin-uninstall.feature b/features/plugin-uninstall.feature index 86ef9dbe..e267507b 100644 --- a/features/plugin-uninstall.feature +++ b/features/plugin-uninstall.feature @@ -79,3 +79,15 @@ Feature: Uninstall a WordPress plugin Success: No plugins uninstalled. """ And the return code should be 0 + + + + Scenario: Excluding a missing plugin should not throw an error + Given a WP install + And I run `wp plugin uninstall --all --exclude=missing-plugin` + Then STDERR should be empty + And STDOUT should contain: + """ + Success: + """ + And the return code should be 0 diff --git a/features/plugin-update.feature b/features/plugin-update.feature index 1a884135..1aa586b7 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -218,3 +218,13 @@ Feature: Update WordPress plugins """ Success: """ + + Scenario: Excluding a missing plugin should not throw an error + Given a WP install + And I run `wp plugin update --all --exclude=missing-plugin` + Then STDERR should be empty + And STDOUT should contain: + """ + Success: + """ + And the return code should be 0 diff --git a/features/theme.feature b/features/theme.feature index 660452d5..470bed9c 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -673,3 +673,15 @@ Feature: Manage WordPress themes When I try `wp theme is-active p2` Then the return code should be 1 + + Scenario: Excluding a missing theme should not throw an error + Given a WP install + And I run `wp theme delete --all --force` + And I run `wp theme install p2 --version=1.5.5 --activate` + And I run `wp theme update --all --exclude=missing-theme` + Then STDERR should be empty + And STDOUT should contain: + """ + Success: + """ + And the return code should be 0 diff --git a/src/WP_CLI/CommandWithUpgrade.php b/src/WP_CLI/CommandWithUpgrade.php index 27f4a3ec..b95cf4f6 100755 --- a/src/WP_CLI/CommandWithUpgrade.php +++ b/src/WP_CLI/CommandWithUpgrade.php @@ -360,9 +360,15 @@ protected function update_many( $args, $assoc_args ) { foreach ( $exclude_items as $item ) { if ( 'plugin' === $this->item_type ) { $plugin = $this->fetcher->get( $item ); + if ( ! $plugin ) { + continue; + } unset( $items_to_update[ $plugin->file ] ); } elseif ( 'theme' === $this->item_type ) { $theme_root = get_theme_root() . '/' . $item; + if ( ! is_dir( $theme_root ) ) { + continue; + } unset( $items_to_update[ $theme_root ] ); } }