Fix incorrect version number when creating zip archive#124
Merged
swissspidy merged 2 commits intomainfrom Mar 12, 2026
Merged
Conversation
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix incorrect version number used when creating zip archive
Fix incorrect version number when creating zip archive
Mar 12, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect version detection for wp dist-archive when scanning PHP files in alphabetical order by ensuring only WordPress-style Version: headers (with a colon) are matched, not PHPdoc @version tags.
Changes:
- Update PHP version detection to use a WordPress
get_file_data()-style regex that requiresVersion:(colon required). - Remove now-unused docblock/token parsing helpers used for version extraction.
- Add a Behat scenario that reproduces the original bug (alphabetically earlier
@versiontag vs. main pluginVersion:header).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Dist_Archive_Command.php |
Switches plugin version extraction to a Version:-header regex and removes docblock-based parsing methods. |
features/dist-archive.feature |
Adds regression coverage ensuring Version: wins over PHPdoc @version when naming the archive. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When PHP files are scanned alphabetically for a plugin version, PHPdoc
@versiontags (e.g. inclass-lifterlms.php) were incorrectly matched before the WordPress plugin headerVersion:in the main plugin file.Root cause: The docblock parser matched both
@version 7.2.0(no colon, PHPdoc) andVersion: 7.6.0(with colon, WP plugin header). Any file alphabetically preceding the main plugin file with a@versiontag would win.Changes:
src/Dist_Archive_Command.php: Replace docblock-based version detection for PHP files with the WordPressget_file_data()style regex, which requires a colon afterVersion:@version 7.2.0(no colon) no longer matches;* Version: 7.6.0does. Removes the now-deadget_version_in_code(),get_version_in_docblock(), andparse_doc_block()methods.features/dist-archive.feature: Adds a scenario that directly reproduces the bug — a plugin directory whereclass-my-plugin.php(with@version 7.2.0) sorts beforemy-plugin.php(withVersion: 7.6.0) — asserting the archive is named using7.6.0.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.