Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#27754 closed enhancement (fixed)

Add ability to filter WP_Upgrader packages before upgrade

Reported by: nofearinc's profile nofearinc Owned by: dd32's profile dd32
Milestone: 4.3 Priority: normal
Severity: normal Version: 3.8
Component: Upgrade/Install Keywords: has-patch commit
Focuses: Cc:

Description

Although #22378 adds a upgrader_pre_download filter which allows for denying a package for an update, there are cases where we would need to filter the package options or even trigger the upgrader_pre_download filter based on other arguments before that.

A good example would be changing the destination to a local file or an internal repository (like a CDN for plugins) for an internal network for bandwidth or speed purposes.

I'm adding a sample upgrader_package_options filter right before extracting the options in the run() function which is the central point and the last step in the stack for this after calling functions like install() or upgrade() have been fired from different places.

Attachments (5)

27754.patch (487 bytes) - added by nofearinc 10 years ago.
27754.2.patch (1.2 KB) - added by nofearinc 10 years ago.
Updated hook docs
27754.3.patch (1.2 KB) - added by nofearinc 10 years ago.
Fix tabs used for two comment arguments
27754.4.patch (1.2 KB) - added by chrisjean 9 years ago.
Refresh of the 27754.3.patch based on 4.3-alpha-32330.
27754.5.patch (1.3 KB) - added by aaroncampbell 9 years ago.
.4 but from root of develop

Download all attachments as: .zip

Change History (12)

@nofearinc
10 years ago

#1 @DrewAPicture
10 years ago

  • Keywords needs-docs added

You'll also need hook documentation here.

@nofearinc
10 years ago

Updated hook docs

@nofearinc
10 years ago

Fix tabs used for two comment arguments

@chrisjean
9 years ago

Refresh of the 27754.3.patch based on 4.3-alpha-32330.

#2 @chrisjean
9 years ago

I refreshed the patch.

I'm personally interested in this update since without this filter, many functions hardwire clear_destination to false. This results in difficulties when users attempt to upgrade existing plugins or themes by supplying a zip file.

With this filter, more advanced install and upgrade features can be implemented without having to create custom implementations of the various upgrader classes just for the purpose of customizing these arguments.

@aaroncampbell
9 years ago

.4 but from root of develop

#3 @aaroncampbell
9 years ago

  • Keywords commit added; needs-docs removed
  • Milestone changed from Awaiting Review to 4.3

Looks like a useful filter that doesn't seem to be able to be handled elsewhere.

#4 @obenland
9 years ago

  • Owner set to aaroncampbell
  • Status changed from new to assigned

#5 @nacin
9 years ago

  • Owner changed from aaroncampbell to dd32

If @dd32 is OK with this, I am too.

#6 @dd32
9 years ago

The filter opens the possibility for plugins to do a lot of stuff they shouldn't, but plugins can already break things in amazing ways :) So it looks fine to me.

As for the use-case of using a local CDN for update packages, it feels like they would be better served by a caching proxy, but understand why that's not a ideal solution to many.

#7 @dd32
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 32783:

Updats: Add a filter for the options params for the update being performed.
Props nofearinc. Fixes #27754

Note: See TracTickets for help on using tickets.