Skip to content

Conversation

@davidperezgar
Copy link
Member

Fixes #1134

This check validates that the "Tested up to" header matches between the plugin's main file header and the readme.txt file.

Problem

The "Tested up to" header can exist in both:

  • The plugin's main file header
  • The plugin's readme.txt file

When both are present, they must be exactly the same. If they differ, it can lead to:

  • Inconsistent version information displayed on WordPress.org
  • Confusion about which WordPress version the plugin actually supports
  • The plugin header value overriding the readme value

Solution

The check has been integrated into the Plugin_Header_Fields_Check class and performs the following validation:

  1. Skips single-file plugins - Single-file plugins don't have readme.txt files
  2. Checks for readme existence - If no readme exists, the check is skipped
  3. Compares major versions - Extracts the major version (e.g., "6.7" from "6.7.1") from both locations
  4. Reports mismatch - If both values exist and don't match, an error is reported
  5. Refactored the Find_Readme trait into a more generic Readme_Utils trait and moved the get_readme_tested_value() method from Plugin_Header_Fields_Check into it for better code reusability.

Implementation Details

Location

  • Check Class: includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php
  • Method: check_tested_up_to_mismatch()
  • Test File: tests/phpunit/tests/Checker/Checks/Tested_Up_To_Check_Tests.php
  • Additional Tests: Added to tests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.php

Error Code

  • mismatched_tested_up_to_header

Severity

  • 7 (Error)

Test Coverage

The following test cases are included:

  1. test_run_with_mismatch() - Verifies error is reported when values don't match
  2. test_run_with_match() - Verifies no error when values match
  3. test_run_with_readme_only() - Verifies no error when only readme has the value
  4. test_run_with_header_only() - Verifies no error when only header has the value
  5. test_run_with_single_file_plugin() - Verifies single-file plugins are skipped
  6. test_run_with_no_readme() - Verifies no error when readme doesn't exist
  7. Tests added to Plugin_Header_Fields_Check_Tests.php for integration testing

Usage

The check runs automatically as part of the Plugin_Header_Fields_Check and will report errors when:

  • Both readme.txt and plugin header contain "Tested up to" values
  • The major versions don't match

Error Message

When a mismatch is detected, the following error is displayed:

Mismatched "Tested up to": {readme_version} != {plugin_header_version}.

The "Tested up to" value in the readme file must match the "Tested up to" value in the plugin header. 
If the plugin header has a "Tested up to" value, it will override the readme value, which can cause confusion.

Documentation URL

https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#readme-header-information

@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: davidperezgar <davidperez@git.wordpress.org>
Co-authored-by: ernilambar <nilambar@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@davidperezgar davidperezgar added this to the 1.8.0 milestone Dec 20, 2025

// Get the "Tested up to" value from the plugin header.
$plugin_header = get_file_data(
$plugin_main_file,
Copy link
Member

Choose a reason for hiding this comment

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

We already have helper for this "private function get_plugin_data()"

Copy link
Member

Choose a reason for hiding this comment

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

Moreover this check should be in 'Plugin_Header_Fields_Check.php" class.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's easier in Readme as the readme parser is already loaded. My first approach was to load in the Header fields and you need more functions to load.


// The "Tested up to" mismatch check has been moved to Plugin_Readme_Check.
// This test now verifies that Plugin_Header_Fields_Check does NOT report this error.
if ( isset( $errors['load.php'][0][0] ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

We should try to avoid such "if" conditionals in the unit tests.

// Note: Other readme errors may still be present.
if ( ! empty( $errors ) ) {
foreach ( $errors as $file => $file_errors ) {
if ( isset( $file_errors[0][0] ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

"wp_list_filter" approach is better to fetch code here I guess.

@@ -0,0 +1,145 @@
<?php
/**
Copy link
Member

Choose a reason for hiding this comment

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

Instead of creating separate file for this "Tested_Up_To_Check_Tests.php", we could include it in "Plugin_Header_Fields_Check_Tests.php" to simplify.

Copy link
Member Author

Choose a reason for hiding this comment

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

The check is in readme checks.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's part of Readme checks, not Plugin Header.

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.

Mismatched "Tested up to" header between Plugin Header and Readme

3 participants