Decouple package filename from package metadata#500
Draft
kasparsd wants to merge 12 commits into
Draft
Conversation
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
Contributor
kasparsd
commented
May 18, 2026
| // 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 ] ); |
Contributor
Author
There was a problem hiding this comment.
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:
- doesn't know about the actual paths on the filesystem,
- 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 { |
Contributor
Author
There was a problem hiding this comment.
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, |
Contributor
Author
There was a problem hiding this comment.
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.
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.
Filename is a dynamic property that WP resolves during runtime. It shouldn't be part of package metadata.
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
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