Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#30441 closed enhancement (fixed)

New action hook in auto-upgrade process

Reported by: davidanderson's profile DavidAnderson Owned by: drewapicture's profile DrewAPicture
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.7
Component: Upgrade/Install Keywords: has-patch dev-feedback
Focuses: Cc:

Description

The attached patch adds an action hook in the automatic (background) upgrading process.

I have a need for such a hook in a plugin. (I wish to record some state information pre-update). Currently, if you want to do this, then it's very ugly and hackish: the nearest you can get is to use the should_update filter, and duplicate part of the WP_Automatic_Updater::should_update() method within your filter (the part that comes after the filter is called - because that can also prevent the update). And even so, it's a filter: someone else might decide to call it for a different reason other than a real update going ahead, so, you've also got to do stuff with doing_action() to make sure of your context.

Attachments (2)

pre-auto-update.patch (388 bytes) - added by DavidAnderson 10 years ago.
Add action call before background updates
pre-auto-update.2.patch (849 bytes) - added by welcher 10 years ago.
Adding inline docs

Download all attachments as: .zip

Change History (12)

@DavidAnderson
10 years ago

Add action call before background updates

#1 in reply to: ↑ description @DavidAnderson
10 years ago

Replying to DavidAnderson:

the nearest you can get is to use the should_update filter

I meant to say, "the auto_update_* filters".

#2 @boonebgorges
10 years ago

  • Version changed from trunk to 3.7

#3 @SergeyBiryukov
10 years ago

  • Focuses docs added

The filter needs to be documented as per the documentation standards.

@welcher
10 years ago

Adding inline docs

#4 @welcher
10 years ago

  • Keywords has-patch added

#5 @adamsilverstein
10 years ago

  • Keywords dev-feedback added

#6 @maximinime
9 years ago

Is there any reason this hasn't been added yet? I was very surprised to find out there is no reliable way to trigger a backup of important files, db data, do notifications, etc. prior to updates.

It would be worthwhile having similar hooks for manual updates, too, considering it's easy to just update everything and brick a site because of some minor error or plugin conflict.

#7 @DrewAPicture
9 years ago

  • Focuses docs removed

#8 @wonderboymusic
9 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Owner set to DrewAPicture
  • Status changed from new to assigned

you might be into this, needs only minor formatting changes + single quotes

#9 @DrewAPicture
9 years ago

  • Status changed from assigned to accepted

#10 @DrewAPicture
9 years ago

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

In 35144:

Upgrader: Introduce a new action hook pre_auto_update, which fires immediately prior to an auto-update for core, themes, plugins, or translations.

Props DavidAnderson, welcher.
Fixes #30441.

Note: See TracTickets for help on using tickets.