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

Run checks in the context of the minimum WP version supported by a plugin #384

Merged
merged 8 commits into from
Jan 15, 2024

Conversation

dd32
Copy link
Member

@dd32 dd32 commented Jan 11, 2024

Some PHPCS rules are WordPress version dependent, only being triggered for older (or newer) versions of WordPress.

One such rule is this, which is triggered unless the minimum wp is set to 6.2:

LINE  84: ERROR Unsupported placeholder used in $wpdb->prepare(). Found: "%i".
                (WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder)
>>  84:  ········$count·=·$wpdb->get_var($wpdb->prepare("SELECT·COUNT(*)·FROM·%i",·$table_name));

WPCS allows setting the minimum required WP version, which this PR implements
https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#setting-minimum-supported-wp-version-from-the-command-line-wordpresscs-0140

I've not added a unit test for this, as I wasn't immediately able to figure out how to do so, but this PR works in my initial testing.

@joemcgill
Copy link
Member

Thanks @dd32. This does seem like something the Plugin Check plugin should account for. It would be great to get some tests added for this functionality if you have time.

Additionally, it seems this issue currently effects the current version of the plugin published to the .org repo, which is currently in the legacy-plugin branch of the repo, so applying a similar change there may be needed until #283 is resolved and version 1.0.0 can be released.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dd32, great catch! I left some feedback below.

includes/Traits/Find_Readme.php Show resolved Hide resolved
includes/Plugin_Context.php Outdated Show resolved Hide resolved
includes/Plugin_Context.php Outdated Show resolved Hide resolved
includes/Plugin_Context.php Outdated Show resolved Hide resolved
includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php Outdated Show resolved Hide resolved
@dd32
Copy link
Member Author

dd32 commented Jan 13, 2024

It would be great to get some tests added for this functionality if you have time.

Feel free to add them, as I said, I couldn't figure out how to in the overcomplicated abstractions.

Additionally, it seems this issue currently effects the current version of the plugin published to the .org repo, which is currently in the legacy-plugin branch of the repo, so applying a similar change there may be needed until #283 is resolved and version 1.0.0 can be released.

Probably, but I don't think that's a priority, since AFAIK the legacy version should be abandoned in its entirety based on how things have been moving

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dd32!

@swissspidy swissspidy merged commit a988af9 into WordPress:trunk Jan 15, 2024
24 checks passed
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 this pull request may close these issues.

4 participants