From 61803a37a41eca95efe964c7e02c768de6df75fa Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 7 Jul 2020 19:13:30 +0000 Subject: [PATCH] Upgrade/Install: Add `hook_extra` parameter to the `upgrader_pre_download` filter. This provides additional context to code running on this hook, including which plugin or theme update will be downloaded. It also brings consistency to this filter with others throughout the upgrade process. Props obliviousharmony, desrosj. Fixes #49686. git-svn-id: https://develop.svn.wordpress.org/trunk@48399 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/class-wp-upgrader.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 1a63096892..d4244fb026 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -248,21 +248,22 @@ class WP_Upgrader { * @param string $package The URI of the package. If this is the full path to an * existing local file, it will be returned untouched. * @param bool $check_signatures Whether to validate file signatures. Default false. + * @param array $hook_extra Extra arguments to pass to the filter hooks. Default empty array. * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object. */ - public function download_package( $package, $check_signatures = false ) { - + public function download_package( $package, $check_signatures = false, $hook_extra = array() ) { /** * Filters whether to return the package. * * @since 3.7.0 * - * @param bool $reply Whether to bail without returning the package. - * Default false. - * @param string $package The package file name. - * @param WP_Upgrader $this The WP_Upgrader instance. + * @param bool $reply Whether to bail without returning the package. + * Default false. + * @param string $package The package file name. + * @param WP_Upgrader $this The WP_Upgrader instance. + * @param array $hook_extra Extra arguments passed to hooked filters. */ - $reply = apply_filters( 'upgrader_pre_download', false, $package, $this ); + $reply = apply_filters( 'upgrader_pre_download', false, $package, $this, $hook_extra ); if ( false !== $reply ) { return $reply; } @@ -737,7 +738,7 @@ class WP_Upgrader { * Download the package (Note, This just returns the filename * of the file if the package is a local file) */ - $download = $this->download_package( $options['package'], true ); + $download = $this->download_package( $options['package'], true, $options['hook_extra'] ); // Allow for signature soft-fail. // WARNING: This may be removed in the future.