From b39c5d7f3f55c118e819fd43cd0111d1c67f7ae2 Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Mon, 2 Feb 2026 13:52:25 +0530 Subject: [PATCH 1/5] CoreTrac-64568 Add wp_clean_plugins_cache to remove stale data after plugin uninstall --- src/wp-admin/includes/plugin.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 460874ca52181..f766faf9078a6 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 ) ) ); } + // Clean up plugin cache to remove stale data after plugin deletion. + wp_clean_plugins_cache(); + return true; } From 0677f37e3af7003cb3a1426593ab3d7c6db6a22d Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Mon, 2 Feb 2026 13:54:01 +0530 Subject: [PATCH 2/5] CoreTrac-64568 Update messaging for comment --- src/wp-admin/includes/plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index f766faf9078a6..e377ee172a61f 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -1054,7 +1054,7 @@ function delete_plugins( $plugins, $deprecated = '' ) { return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) ); } - // Clean up plugin cache to remove stale data after plugin deletion. + // Clears the plugin cache to remove stale data following plugin deletion. wp_clean_plugins_cache(); return true; From 60e7d091661ad072acc2656d2c95f531c317e084 Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Mon, 9 Feb 2026 15:21:05 +0530 Subject: [PATCH 3/5] Update the comment with new wordings --- src/wp-admin/includes/plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index e377ee172a61f..a788d0289556f 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -1054,7 +1054,7 @@ function delete_plugins( $plugins, $deprecated = '' ) { return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) ); } - // Clears the plugin cache to remove stale data following plugin deletion. + // Force refresh of plugin update information. wp_clean_plugins_cache(); return true; From 3e61a6cb53b5744832ddb8f75d7e1ec04ccf34f6 Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Mon, 9 Feb 2026 16:00:40 +0530 Subject: [PATCH 4/5] Add the unit test to verify the cache is deleted once delete_plugin is called --- tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php b/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php index 1fc3d9422d85b..6d2042f7df762 100644 --- a/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php +++ b/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php @@ -131,6 +131,7 @@ public function test_invalid_file() { * @group ms-excluded * * @covers ::delete_plugins + * @covers ::wp_clean_plugins_cache */ public function test_delete_plugin() { $this->_setRole( 'administrator' ); @@ -139,6 +140,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 +172,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()' ); } } From 75a44c2c3fb3725358d6476eaca930942c712e3a Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Mon, 9 Feb 2026 16:01:49 +0530 Subject: [PATCH 5/5] Add @ticket comment to test function --- tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php b/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php index 6d2042f7df762..35c8aad217d95 100644 --- a/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php +++ b/tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php @@ -131,7 +131,8 @@ public function test_invalid_file() { * @group ms-excluded * * @covers ::delete_plugins - * @covers ::wp_clean_plugins_cache + * + * @ticket 64568 */ public function test_delete_plugin() { $this->_setRole( 'administrator' );