Skip to content

Decouple package filename from package metadata#500

Draft
kasparsd wants to merge 12 commits into
fairpm:mainfrom
kasparsd:package-data-refactor
Draft

Decouple package filename from package metadata#500
kasparsd wants to merge 12 commits into
fairpm:mainfrom
kasparsd:package-data-refactor

Conversation

@kasparsd
Copy link
Copy Markdown
Contributor

@kasparsd kasparsd commented May 18, 2026

Filename is a dynamic property that WP resolves during runtime. It shouldn't be part of package metadata.

  1. During an update WP already knows the plugin bootstrap (basename) file from the option: https://github.com/WordPress/wordpress-develop/blob/5a96ff4d54a97955b02ac3c20f3ae7f21185232f/src/wp-includes/update.php#L570

  2. And during a fresh plugin install it resolves it by scanning all PHP files in the root of newly installed plugin for the header: https://github.com/WordPress/wordpress-develop/blob/5a96ff4d54a97955b02ac3c20f3ae7f21185232f/src/wp-admin/includes/plugin-install.php#L469

kasparsd and others added 12 commits May 16, 2026 11:27
Signed-off-by: Kaspars Dambis <hi@kaspars.net>
This sample metadata doesn’t have filename returned, for reference https://github.com/fairpm/fair-plugin/releases/latest/download/fair-metadata.json

Signed-off-by: Kaspars Dambis <hi@kaspars.net>
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
Signed-off-by: Kaspars Dambis <hi@kaspars.net>
Signed-off-by: Kaspars Dambis <hi@kaspars.net>
Signed-off-by: Kaspars Dambis <hi@kaspars.net>
…the DID hash appended

Signed-off-by: Kaspars Dambis <hi@kaspars.net>
also none of these functions are used elsewhere, keep inline for now
@github-actions
Copy link
Copy Markdown
Contributor

// Get the plugin basenames for the DIDs.
foreach ( $dids as $did ) {
if ( ! empty( $packages['plugins'][ $did ] ) ) {
$plugin_basename_by_did[ $did ] = plugin_basename( $packages['plugins'][ $did ] );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here we collect the plugin basenames from what WP core reports via get_plugins() and wp_get_themes() which has the correct filename data, instead of asking for that data to Packages\get_hashed_filename( $metadata ) which:

  1. doesn't know about the actual paths on the filesystem,
  2. and could report a different filename than what is on the filesystem.

function get_hashed_filename( $metadata ) : string {
$filename = $metadata->filename;
$type = str_replace( 'wp-', '', $metadata->type );
function get_hashed_slug( $metadata ) : string {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Never attempt to return the package filename since it can't be done reliably and can mismatch what is on the filesystem. This function now reports the desired slug/directory for this package.

'author_uri' => $metadata->authors[0]->url,
'slug' => $metadata->slug,
'slug_didhash' => $metadata->slug . '-' . get_did_hash( $did ),
$type => $filename,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is injected during update_site_transient() instead when we actually know the current filename on the filesystem which is what WP core uses for the lifecycle of the update.

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