Skip to content

Plugins: Store releases as CPT records#675

Open
dd32 wants to merge 6 commits into
WordPress:trunkfrom
dd32:issue-664-release-cpt
Open

Plugins: Store releases as CPT records#675
dd32 wants to merge 6 commits into
WordPress:trunkfrom
dd32:issue-664-release-cpt

Conversation

@dd32
Copy link
Copy Markdown
Member

@dd32 dd32 commented Jun 5, 2026

Summary

  • Extracts a headless plugin_release CPT from PR Add a release page #407 without the release-page UI/components.
  • Replaces the Plugin_Directory::get_release(s), add_release(), and remove_release() storage layer with CPT-backed records while preserving the legacy release array shape used by release confirmations, ZIP building, and cooldown code.
  • Lazily backfills CPT records from existing releases postmeta, then tags metadata/SVN as the existing polyfill path did, and mirrors PR Add a release page #407-style release meta for future UI work.
  • Adds focused tests for CPT writes, legacy meta backfill, update/merge behavior, unconfirmed release removal, and the trunk@version lookup fallback.

Testing

  • php -l wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
  • php -l wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-release.php
  • php -l wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/Plugin_Release_Test.php
  • ./vendor/bin/phpcs --standard=wordpress.org/public_html/wp-content/plugins/plugin-directory/phpcs.xml.dist wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-release.php wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/Plugin_Release_Test.php
  • git diff --check

Targeted PHPUnit was attempted with WP_TESTS_DIR=/home/user/wordpress-develop/tests/phpunit ./vendor/bin/phpunit -c wordpress.org/public_html/wp-content/plugins/plugin-directory/phpunit.xml --filter Plugin_Release_Test, but local WordPress bootstrap fails because this PHP runtime has no MySQLi extension.

Refs #664, #407.

Copilot AI review requested due to automatic review settings June 5, 2026 02:52
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dd32.

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the Plugin Directory “releases” storage layer from a single releases postmeta array to a private plugin_release custom post type (CPT), while preserving the legacy release array contract consumed by existing cooldown/ZIP/confirmation code paths.

Changes:

  • Introduces a headless Plugin_Release storage/compatibility layer backed by a private plugin_release CPT, with lazy backfill from legacy releases postmeta and (fallback) tags/SVN metadata.
  • Replaces Plugin_Directory::get_release(s), add_release(), and remove_release() to delegate to the new CPT-backed implementation.
  • Adds PHPUnit coverage for CPT writes, lazy backfill, merge/update semantics, unconfirmed deletion rules, and the trunk@version fallback.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php Switches the public legacy release APIs to delegate to the new CPT-backed layer and initializes release support.
wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-release.php Adds the CPT storage + legacy compatibility implementation, including lazy migration/backfill logic.
wordpress.org/public_html/wp-content/plugins/plugin-directory/tests/Plugin_Release_Test.php Adds focused tests covering CPT persistence, backfill behavior, updates/merges, deletion rules, and trunk fallback.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +235 to +255
public function get_release( $plugin, $tag ) {
$releases = $this->get_releases( $plugin );

$filtered = wp_list_filter( $releases, compact( 'tag' ) );
if ( $filtered ) {
return array_shift( $filtered );
}

$filtered = wp_list_filter(
$releases,
array(
'tag' => "trunk@{$tag}",
'version' => $tag,
)
);
if ( $filtered ) {
return array_shift( $filtered );
}

return false;
}
Copilot AI review requested due to automatic review settings June 5, 2026 03:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

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.

2 participants