Skip to content

Enforce Tested up to exclusively in the readme file #1464

Description

@davidperezgar

Problem

Plugin Check currently reports an error only when the Tested up to value in the main plugin PHP header differs from the value in readme.txt.

This validates duplicated declarations when both values match, despite Tested up to being readme metadata. Keeping it in both places creates two sources of truth that can silently drift in a future release.

The internal plugin-review scanner already reports any Tested up to declaration in the main PHP file and asks authors to keep it only in the readme.

Proposed change

Replace the current mismatch-only validation in Plugin_Readme_Check::check_tested_up_to_mismatch() with a presence check:

  • Report an error whenever the main plugin file declares Tested up to.
  • Do this whether the readme value is missing, equal, or different.
  • Attach the finding to the main plugin file.
  • Keep the readme value in the message when available:
    • If different, show both values to explain the immediate inconsistency.
    • If equal, explain that duplication can get out of sync.
  • In all cases, instruct authors to remove the Tested up to line from the PHP header and retain it only in readme.txt.

Suggested error code: plugin_header_tested_up_to_not_allowed.

Suggested message:

The Tested up to field must be declared only in the plugin readme file. Remove it from the main plugin PHP header.

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

Existing implementation

  • includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php
    • check_tested_up_to_mismatch() currently returns early unless both values exist and only reports differing normalized versions.
  • tests/phpunit/testdata/plugins/
    • Existing fixtures already cover matching, mismatching, readme-only, and header-only declarations.

Acceptance criteria

  • A plugin with matching Tested up to values in readme.txt and the main PHP header reports one error.
  • A plugin with differing values reports one error, with both values included in the message.
  • A plugin with Tested up to only in the main PHP header reports one error.
  • A plugin with Tested up to only in readme.txt reports no error for this rule.
  • The existing mismatch-specific test expectations and fixtures are renamed or updated to reflect the new rule.
  • The rule remains limited to directory plugins; single-file plugin behavior is preserved unless explicitly decided otherwise.

AI disclosure

This issue was drafted with AI assistance. The proposed problem statement, scope, and acceptance criteria were reviewed by a human before submission.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions