From 87f464c2836c9a786605637e18c3e00457446a2b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 5 Jul 2020 20:32:03 +0000 Subject: [PATCH] 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 --- wp-admin/includes/plugin.php | 12 ++++++++---- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 914ef15df2..94d5b856a6 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -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; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 9fc494fe56..477f248cbc 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @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.