-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade/Install: Roll back a plugin auto-update with a fatal error. #5287
Upgrade/Install: Roll back a plugin auto-update with a fatal error. #5287
Conversation
@costdev and I have been testing all combinations of plugins, fataling plugin, and themes with this, even @peterwilsoncc's list of plugins. It tests out great! |
c49a17d
to
edec89e
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
56a2298
to
db5b5c4
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @[email protected]. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
db5b5c4
to
d3a1813
Compare
`get_transient()`, options and the database aren't available this early in the bootstrap.
Co-authored-by: Andy Fragen <[email protected]>
9ff3a78
to
7a8a3f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should better integrate without the need to return a WP_Error
Co-authored-by: Andy Fragen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few comments :)
I added some minor code review comments, but in general it's looking good. I'm going to functionally test this over the next few days. |
Co-authored-by: John Blackbourn <[email protected]>
Co-authored-by: John Blackbourn <[email protected]>
Co-authored-by: Colin Stewart <[email protected]>
/* | ||
* Avoids a race condition when there are 2 sequential plugins that have fatal errors. | ||
* WP_Automatic_Updater::update() can be called for the second plugin before the first has | ||
* finished checking for fatal errors. This can cause the second plugin's fatal error checking to be skipped, | ||
* and may affect subsequent plugins too. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
* Avoids a race condition when there are 2 sequential plugins that have fatal errors. | |
* WP_Automatic_Updater::update() can be called for the second plugin before the first has | |
* finished checking for fatal errors. This can cause the second plugin's fatal error checking to be skipped, | |
* and may affect subsequent plugins too. | |
*/ | |
/* | |
* Avoids a race condition when there are 2 sequential plugins that have fatal errors. | |
* It seems a slight delay is required for the loopback to use the updated plugin code in the request. | |
* This can cause the second plugin's fatal error checking to be inaccurate, | |
* and may also affect subsequent plugin checks. | |
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that documenting what doesn't work is useful here, but posting on the ticket what's been checked and verified is worth doing for posterity. In the code, we should document the reasoning for the sleep, and ensure that we've verified the details as much as we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By all means modify as necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
What shall we do with all the |
For debugging purposes, since this is a background task, it would be great if we could put them behind a |
I say leave them for now for broader testing. Somewhere around beta1 we can put the loopback results behind WP_DEBUG and remove most of the others. |
The biggest concern when plugins update automatically is that they may contain a fatal error that crashes a website.
This performs a loopback request to the homepage in an attempt to detect such fatal errors in an active plugin after updating. This ensures that only the plugin's new code has been loaded into memory, and prevents false positives when, for example, a plugin may include a class definition in the main plugin file.
Should a fatal error be detected, the update is restored to the previously installed version.
The loopback request is also performed for the Plugin File Editor and Theme File Editor. However, the implementation here does not distinguish between a failed loopback request and a plugin with no fatal errors, as the aim is to make the best attempt to detect a fatal error.
Additionally, the Site Health error message for the loopback request test states:
So if loopback requests are not possible, automatic updates should not be possible anyway. 🙂
Trac ticket: https://core.trac.wordpress.org/ticket/58281