Plugins: Use include_once instead of include in uninstall_plugin(), in case the plugin file is already included.

Props valchovski, pcfreak30.
Fixes #47796.
Built from https://develop.svn.wordpress.org/trunk@48326


git-svn-id: http://core.svn.wordpress.org/trunk@48095 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-07-05 20:32:03 +00:00
parent 514ba95009
commit 87f464c283
2 changed files with 9 additions and 5 deletions

View File

@ -658,11 +658,13 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
} }
ob_start(); ob_start();
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
$_wp_plugin_file = $plugin;
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) { if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
define( 'WP_SANDBOX_SCRAPING', true ); define( 'WP_SANDBOX_SCRAPING', true );
} }
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
$_wp_plugin_file = $plugin;
include_once WP_PLUGIN_DIR . '/' . $plugin; include_once WP_PLUGIN_DIR . '/' . $plugin;
$plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin. $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin.
@ -1252,8 +1254,9 @@ function uninstall_plugin( $plugin ) {
unset( $uninstallable_plugins ); unset( $uninstallable_plugins );
define( 'WP_UNINSTALL_PLUGIN', $file ); define( 'WP_UNINSTALL_PLUGIN', $file );
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
include WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php'; include_once WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php';
return true; return true;
} }
@ -1265,7 +1268,7 @@ function uninstall_plugin( $plugin ) {
unset( $uninstallable_plugins ); unset( $uninstallable_plugins );
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file ); wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
include WP_PLUGIN_DIR . '/' . $file; include_once WP_PLUGIN_DIR . '/' . $file;
add_action( "uninstall_{$file}", $callable ); add_action( "uninstall_{$file}", $callable );
@ -2287,6 +2290,7 @@ function plugin_sandbox_scrape( $plugin ) {
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) { if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
define( 'WP_SANDBOX_SCRAPING', true ); define( 'WP_SANDBOX_SCRAPING', true );
} }
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
include WP_PLUGIN_DIR . '/' . $plugin; include WP_PLUGIN_DIR . '/' . $plugin;
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.5-alpha-48325'; $wp_version = '5.5-alpha-48326';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.