Skip to content
Permalink
Browse files

Options: `register_uninstall_hook()` causes large amounts of unnecess…

…ary option updates.

Prevent extra database read/writes from the the hook.

Props jeichorn, MikeHansenMe, DrewAPicture, Rahe, tha_sun, mikeschroder.
Fixes #31792.



git-svn-id: https://develop.svn.wordpress.org/trunk@46333 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
whyisjake committed Sep 26, 2019
1 parent f2e9aa7 commit ea1d3b13cc3fe52f3818fffd6e3ea09d996f6438
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/wp-includes/plugin.php
@@ -840,10 +840,12 @@ function register_uninstall_hook( $file, $callback ) {
* cases. Emphasis should be put on using the 'uninstall.php' way of
* uninstalling the plugin.
*/
$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
$uninstallable_plugins[ plugin_basename( $file ) ] = $callback;
update_option( 'uninstall_plugins', $uninstallable_plugins );
$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
$plugin_basename = plugin_basename( $file );
if ( ! isset( $uninstallable_plugins[ $plugin_basename ] ) || $uninstallable_plugins[ $plugin_basename ] !== $callback ) {
$uninstallable_plugins[ $plugin_basename ] = $callback;
update_option( 'uninstall_plugins', $uninstallable_plugins );
}
}
/**

0 comments on commit ea1d3b1

Please sign in to comment.
You can’t perform that action at this time.