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

Props valchovski, pcfreak30.
Fixes #47796.

git-svn-id: https://develop.svn.wordpress.org/trunk@48326 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-07-05 20:30:18 +00:00
parent 5c41e3af90
commit b1b1b08e43

View File

@ -658,11 +658,13 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
}
ob_start();
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
$_wp_plugin_file = $plugin;
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
define( 'WP_SANDBOX_SCRAPING', true );
}
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
$_wp_plugin_file = $plugin;
include_once WP_PLUGIN_DIR . '/' . $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 );
define( 'WP_UNINSTALL_PLUGIN', $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;
}
@ -1265,7 +1268,7 @@ function uninstall_plugin( $plugin ) {
unset( $uninstallable_plugins );
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
include WP_PLUGIN_DIR . '/' . $file;
include_once WP_PLUGIN_DIR . '/' . $file;
add_action( "uninstall_{$file}", $callable );
@ -2287,6 +2290,7 @@ function plugin_sandbox_scrape( $plugin ) {
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
define( 'WP_SANDBOX_SCRAPING', true );
}
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
include WP_PLUGIN_DIR . '/' . $plugin;
}