WordPress.org

Make WordPress Core

Changeset 46333


Ignore:
Timestamp:
09/26/2019 10:07:05 PM (4 weeks ago)
Author:
whyisjake
Message:

Options: register_uninstall_hook() causes large amounts of unnecessary option updates.

Prevent extra database read/writes from the the hook.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/plugin.php

    r46322 r46333  
    841841     * uninstalling the plugin.
    842842     */
    843     $uninstallable_plugins                             = (array) get_option( 'uninstall_plugins' );
    844     $uninstallable_plugins[ plugin_basename( $file ) ] = $callback;
    845 
    846     update_option( 'uninstall_plugins', $uninstallable_plugins );
     843    $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
     844    $plugin_basename       = plugin_basename( $file );
     845    if ( ! isset( $uninstallable_plugins[ $plugin_basename ] ) || $uninstallable_plugins[ $plugin_basename ] !== $callback ) {
     846        $uninstallable_plugins[ $plugin_basename ] = $callback;
     847        update_option( 'uninstall_plugins', $uninstallable_plugins );
     848    }
    847849}
    848850
Note: See TracChangeset for help on using the changeset viewer.