plugin-check
plugin-check copied to clipboard
Display warning if non existent parameters are passed in `--checks` and `--categories`
Proper warning message should be displayed rather than fatal error when non existent check is passed to --checks
wp plugin check hello-universe --checks=nonexistent_check
Currently it generates PHP fatal error.
Fatal error: Uncaught Exception: Check with the slug "nonexistent_check" does not exist. in /var/www/html/wp-content/plugins/plugin-check/includes/Checker/Default_Check_Collection.php:158
May be we should display warning message like
WARNING: Invalid check slug 'nonexistent_check'
We could implement similar for categories also.
wp plugin check hello-universe --categories=nonexistent_category
This issue is similar to https://github.com/WordPress/plugin-check/issues/360 . Would it be of worth implementing the validation here for --checks and --categories? Not a critical issue though.
cc: @swissspidy @felixarntz @mukeshpanchal27
I suppose we can catch any exceptions and turn them into proper error messages (not warnings)
I suppose we can catch any exceptions and turn them into proper error messages (not warnings)
@swissspidy Please check https://github.com/WordPress/plugin-check/pull/383
I was thinking more like something like this in the command class:
try {
....
} catch ( Exception $error ) {
WP_CLI::error( $error->getMessage() );
}
We already do this in some places
This fatal error comes before execution reaches to CLI command class. Even when public function check( $args, $assoc_args ) in Plugin_Check_Command function is empty, this error appears.
It is triggered from Plugin_Request_Utility::initialize_runner().
When checking for a non-existent category like wp plugin check hello-universe --categories=nonexistent_category, there is no fatal error. It just doesn't run any check.
Should PCP show a warning?
Yes, I think it should show a warning.