Make WordPress Core

Ticket #31792: plugin.diff

File plugin.diff, 1.1 KB (added by jeichorn, 12 years ago)

wp-include/plugin.diff

  • wp-includes/plugin.php

    diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
    index e5e5288..5db957d 100644
    a b function register_deactivation_hook($file, $function) {  
    784784 * should always check for the 'WP_UNINSTALL_PLUGIN' constant, before
    785785 * executing.
    786786 *
     787 * The registration updates wp_options and so should only be called within an
     788 * activation hook.
     789 *
    787790 * @since 2.7.0
    788791 *
    789792 * @param string   $file     Plugin file.
    … … function register_uninstall_hook( $file, $callback ) {  
    802805        * uninstalling the plugin.
    803806        */
    804807       $uninstallable_plugins = (array) get_option('uninstall_plugins');
    805        $uninstallable_plugins[plugin_basename($file)] = $callback;
    806 
    807        update_option('uninstall_plugins', $uninstallable_plugins);
     808    $key = plugin_basename($file);
     809    if ( empty( $uninstallable_plugins[$key] ) || $uninstallable_plugins[$key] != $callback) {
     810        $uninstallable_plugins[$key] = $callback;
     811        update_option('uninstall_plugins', $uninstallable_plugins);
     812    }
    808813}
    809814
    810815/**