10up / wpcli-vulnerability-scanner

WP-CLI command for checking installed plugins and themes for vulnerabilities reported on wpvulndb.com
MIT License
274 stars 40 forks source link

Fix array to string conversion PHP warning when running with no arguments #88

Closed ruscoe closed 1 year ago

ruscoe commented 1 year ago

Description of the Change

Ensures the $assoc_args array is not empty before attempting to reference it. This fixes the following PHP warning that appears when running wp vuln status with no arguments.

PHP Warning: Array to string conversion in /var/www/wpclean.local/wp-content/plugins/wpcli-vulnerability-scanner/wpcli-vulnerability-scanner.php on line 124

Verified by running with and without arguments before making the change, then repeating after making the change.

Closes #87

How to test the Change

  1. Install this plugin
  2. Ensure PHP is configured to show warnings
  3. Run wp vuln status
  4. You should see the PHP warning as described
  5. Merge this change
  6. Run wp vuln status
  7. You should no longer see the PHP warning

Changelog Entry

Fixed - Array to string conversion PHP warning when running with no arguments

Credits

Props @ruscoe

Checklist:

ruscoe commented 1 year ago

It seems like I was working on an older version of the codebase and this is no longer an issue, so I'm going to close this PR :+1: