Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display warning if non existent parameters are passed in --checks and --categories #348

Open
ernilambar opened this issue Dec 20, 2023 · 5 comments · May be fixed by #389
Open

Display warning if non existent parameters are passed in --checks and --categories #348

ernilambar opened this issue Dec 20, 2023 · 5 comments · May be fixed by #389

Comments

@ernilambar
Copy link
Contributor

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

@ernilambar
Copy link
Contributor Author

This issue is similar to #360 . Would it be of worth implementing the validation here for --checks and --categories? Not a critical issue though.

cc: @swissspidy @felixarntz @mukeshpanchal27

@swissspidy
Copy link
Member

I suppose we can catch any exceptions and turn them into proper error messages (not warnings)

@ernilambar
Copy link
Contributor Author

I suppose we can catch any exceptions and turn them into proper error messages (not warnings)

@swissspidy Please check #383

@swissspidy
Copy link
Member

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

@ernilambar
Copy link
Contributor Author

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants