diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index fae10f1a679a4..46be6f610c447 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -1054,6 +1054,9 @@ function delete_plugins( $plugins, $deprecated = '' ) { return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) ); } + // Force refresh of plugin update information. + wp_clean_plugins_cache(); + return true; } diff --git a/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php b/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php index 1fc3d9422d85b..35c8aad217d95 100644 --- a/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php +++ b/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php @@ -131,6 +131,8 @@ public function test_invalid_file() { * @group ms-excluded * * @covers ::delete_plugins + * + * @ticket 64568 */ public function test_delete_plugin() { $this->_setRole( 'administrator' ); @@ -139,6 +141,17 @@ public function test_delete_plugin() { $_POST['plugin'] = 'foo.php'; $_POST['slug'] = 'foo'; + // Adds the plugin cache. + $plugins_cache = array( + '' => array( + 'foo.php' => array( + 'Name' => 'Foo Plugin', + 'Version' => '1.0', + ), + ), + ); + wp_cache_set( 'plugins', $plugins_cache, 'plugins' ); + // Make the request. try { $this->_handleAjax( 'delete-plugin' ); @@ -160,5 +173,8 @@ public function test_delete_plugin() { ); $this->assertSameSets( $expected, $response ); + + // Verify that wp_clean_plugins_cache() was called and cleared both cache and transient. + $this->assertFalse( wp_cache_get( 'plugins', 'plugins' ), 'Plugins cache should be cleared after delete_plugins()' ); } }