[wp-trac] [WordPress Trac] #34661: add filter to WP_Upgrader::install_package() to filter $this->result
WordPress Trac
noreply at wordpress.org
Wed Nov 11 17:29:07 UTC 2015
#34661: add filter to WP_Upgrader::install_package() to filter $this->result
-----------------------------+-----------------------------
Reporter: afragen | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upgrade/Install | Version: trunk
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
If a plugin or theme updates from a source outside of the .org repo the
downloaded plugin/theme is often in a format that requires renaming so
that it can be correctly moved to a corrected directory structure. As an
example, GitHub downloads are in the format of `user-my-plugin-name-
hash.zip` and when expanded have the format `user-my-plugin-name-hash/my-
plugin-name.php`
From here the outside updater code must rename the directory and move the
files or plugin or theme deactivation will be an issue. Currently there
are 2 filters within the `WP_Upgrader::install_package()` that can be used
to assist `upgrader_source_selection` and `upgrader_post_install`. Both of
these have drawbacks.
`upgrader_source_selection` only allows to change the `$source` and while
this is helpful, it does not allow for changing of any of the other
''destination'' parameters. `upgrader_post_intall` has a more convenient
parameter in `$hook_extra` to aid in renaming of the directory structure
but it's return value is either an error or an array and nothing happens
with a non-error return value.
Manipulating these many of the ''destination'' parameters of
`$this->result` is needed to allow for seamless renaming of these
directories and to allow for these renamed values to be saved. It is the
ability to save these values for use elsewhere that is the principal
benefit of this proposed filter.
As an example, in order to update, move, and keep active the current theme
the `$source` needs to be updated and saved. Though this can be currently
achieved using `upgrader_source_selection` no other parameters can be
saved. As #34617 explains, the version information for plugin updated via
shiny updates returns an empty string if the `destination_name` of
`$this->result` is not the updated destination name. Currently, there is
no method of changing the destination name in the following line from
`wp_ajax_update_plugin()`
{{{
$plugin_data = get_plugins( '/' . $result[ $plugin ]['destination_name']
);
}}}
This results in a ''cosmetic'' bug when updating via shiny updates,
missing version information.
Adding this filter would allow for a simple consistent ability to
manipulate any of the values of the destination in `$this->result` and
have them saved for when they may be referenced elsewhere in code.
I'm not certain how this would effect #27365. This would supersede #34617.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34661>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list