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

Fix incorrect tested up to comparison #779

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,20 @@
if ( ! in_array( $field['ignore_key'], $ignored_warnings, true ) && ! isset( $parser_warnings[ $field['ignore_key'] ] ) ) {

if ( ! empty( $parser->{$field_key} ) && 'tested' === $field_key ) {
list( $tested_upto, ) = explode( '-', $parser->{$field_key} );

if ( preg_match( '#^\d.\d#', $tested_upto, $matches ) ) {
$tested_upto = $matches[0];
}

$latest_wordpress_version = $this->get_wordpress_stable_version();
if ( version_compare( $parser->{$field_key}, $latest_wordpress_version, '<' ) ) {
if ( version_compare( $tested_upto, $latest_wordpress_version, '<' ) ) {
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: 1: currently used version, 2: latest stable WordPress version, 3: 'Tested up to' */
__( '<strong>Tested up to: %1$s < %2$s.</strong><br>The "%3$s" value in your plugin is not set to the current version of WordPress. This means your plugin will not show up in searches, as we require plugins to be compatible and documented as tested up to the most recent version of WordPress.', 'plugin-check' ),
$parser->{$field_key},
$tested_upto,
$latest_wordpress_version,
'Tested up to'
),
Expand All @@ -222,13 +228,13 @@
'https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#readme-header-information',
7
);
} elseif ( version_compare( $parser->{$field_key}, number_format( (float) $latest_wordpress_version + 0.1, 1 ), '>' ) ) {
} elseif ( version_compare( $tested_upto, number_format( (float) $latest_wordpress_version + 0.1, 1 ), '>' ) ) {
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: 1: currently used version, 2: 'Tested up to' */
__( '<strong>Tested up to: %1$s.</strong><br>The "%2$s" value in your plugin is not valid. This version of WordPress does not exist (yet).', 'plugin-check' ),
$parser->{$field_key},
$tested_upto,

Check warning on line 237 in includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php#L237

Added line #L237 was not covered by tests
'Tested up to'
),
'nonexistent_tested_upto_header',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Contributors: https://johndoe.com
Requires at least: 6.0
Tested up to: 6.1
Tested up to: 6.1.0
Requires PHP: 5.6
Stable tag: trunk
License: Oculus VR Inc. Software Development Kit License
Expand Down