Skip to content

Commit

Permalink
Plugins: Store plugin deletion results in temporary option.
Browse files Browse the repository at this point in the history
Storing the data in a non-autoloaded rather than a transient ensures it cannot be accidentally removed due to a cache flush.

Props: kkmuffme, mukesh27.
Fixes #59433.

git-svn-id: https://develop.svn.wordpress.org/trunk@57586 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
swissspidy committed Feb 12, 2024
1 parent 6c5acc3 commit 72bc9c0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/wp-admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,9 @@

$delete_result = delete_plugins( $plugins );

// Store the result in a cache rather than a URL param due to object type & length.
set_transient( 'plugins_delete_result_' . $user_ID, $delete_result );
// Store the result in an option rather than a URL param due to object type & length.
// Cannot use transient/cache, as that could get flushed if any plugin flushes data on uninstall/delete.
update_option( 'plugins_delete_result_' . $user_ID, $delete_result, false );
wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) );
exit;
case 'clear-recent-list':
Expand Down Expand Up @@ -690,9 +691,9 @@
);

} elseif ( isset( $_GET['deleted'] ) ) {
$delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
$delete_result = get_option( 'plugins_delete_result_' . $user_ID );
// Delete it once we're done.
delete_transient( 'plugins_delete_result_' . $user_ID );
delete_option( 'plugins_delete_result_' . $user_ID );

if ( is_wp_error( $delete_result ) ) {
$plugin_not_deleted_message = sprintf(
Expand Down

0 comments on commit 72bc9c0

Please sign in to comment.