Skip to content

fix(wp): make the plugin's WordPress version check read the header it declares - #40

Draft
DavidBabinec wants to merge 1 commit into
mainfrom
fix/wp-requirements-header
Draft

DavidBabinec wants to merge 1 commit into
mainfrom
fix/wp-requirements-header

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

What

The plugin's own WordPress version check never ran. Plugin::data() read a Requires WP header, but core-framework.php declares Requires at least (6.6 since #32), so requiredWP() returned an empty string and Requirements::versionCompare() always passed. Requires PHP was already correct.

The header map is now a Plugin::HEADERS constant, with required-wp pointing at Requires at least. The new PluginHeadersTest checks that every entry is declared in the plugin file and that both requirement values match readme.txt.

Why

WordPress core still blocks activating or updating on an unsupported version. But a site that gets 2.1.0 onto WordPress 6.5 anyway (files copied in by hand, or a core downgrade) kept the plugin active. It now shows the plugin's notice and deactivates on the next admin load. I checked this in Docker with the release ZIP on WordPress 6.5: the plugin stayed active with the old key and deactivated with the fix.

Verification

bun run php-test:wp        # OK (47 tests, 107 assertions); new test fails 2/2 with the old key
bun run e2e:wp             # passed: WordPress 7.0.4, PHP 8.2.33
bun run build:wp && bun run build:figma && bun run check:open-source   # all exit 0

Plugin::data() asked get_file_data() for a "Requires WP" header that
core-framework.php has never declared, so requiredWP() was always an
empty string and the plugin's own WordPress version guard never fired.
The header map is now a class constant so a test can check every entry
against the headers the plugin file actually declares.

This branch has not been deployed

No deployments
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.

1 participant