Plugin Editor: Improve reliability of detecting PHP fatal errors when editing an active plugin.

* Invalidate PHP opcache after file is updated to ensure `include` will ''include'' the written changes.
* Define `WP_ADMIN` when activating plugin in sandbox so plugin code targeting admin will be loaded.
* Do actions that get triggered when loading the admin to ensure plugin code runs that could cause errors on plugin editor screen (and lock out access).
* Fix ability to re-activate a plugin after editing a PHP file other than the main plugin file, and ensure PHP fatal error will be displayed in such cases.
* Consolidate duplicated code into `plugin_sandbox_scrape()` and re-use in `activate_plugin()`.
* Show an error notice instead of a success notice when a file is updated but a plugin was deactivated due to a fatal error.
* Update style of warning when editing an active plugin to be styled as an actual warning notice.

See #12423, #21622.
Fixes #39766.


git-svn-id: https://develop.svn.wordpress.org/trunk@41560 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter
2017-09-22 01:35:09 +00:00
parent e92db998d2
commit f07591d1fd
3 changed files with 71 additions and 12 deletions

View File

@@ -2203,6 +2203,14 @@ h1.nav-tab-wrapper, /* Back-compat for pre-4.4 */
#template > div {
margin-right: 190px;
}
#template .active-plugin-edit-warning {
margin-top: 1em;
margin-right: 30%;
margin-right: calc( 184px + 3% );
}
#template .active-plugin-edit-warning p {
width: auto;
}
.metabox-holder .stuffbox > h3, /* Back-compat for pre-4.4 */
.metabox-holder .postbox > h3, /* Back-compat for pre-4.4 */
@@ -3609,9 +3617,10 @@ img {
margin-top: -5px;
}
#template > div {
#template > div,
#template .active-plugin-edit-warning {
float: none;
margin: 0;
margin: 1em 0;
width: auto;
}