Skip to content

WPQueryParamsSniff incorrectly flags get_users() call #729

@swissspidy

Description

@swissspidy

Bug Description

When using code like get_users( [ 'exclude' => 123 ] ), you'll get a warning like

Using `exclude`, which is subsequently used by `post__not_in`, should be done with caution, see https://docs.wpvip.com/how-tos/improve-performance-by-removing-usage-of-post__not_in/ for more information.

This is wrong because this is not a WP_Query call and does not use post__not_in.

Querying that many users is still not super ideal, but I think this warrants its own sniff that is less confusing.

Minimal Code Snippet

get_users( [ 'exclude' => 123 ] )

Error Code

Environment

Use php -v and composer show to get versions.

Question Answer
PHP version 8.1.12
PHP_CodeSniffer version 3.7.1
VIPCS version 2.3.3

Additional Context (optional)

Tested Against master branch?

  • I have verified the issue still exists in the master branch of VIPCS.
  • I have verified the issue still exists in the develop branch of VIPCS.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions