From 5aae8adf6b257e51d5e77b488384869742333fae Mon Sep 17 00:00:00 2001 From: merkys7 Date: Fri, 29 Jul 2022 01:55:12 +0300 Subject: [PATCH 1/2] Remove plugin option for Multisite during uninstall --- uninstall.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/uninstall.php b/uninstall.php index bb5cb13fdc..908bfc57f3 100644 --- a/uninstall.php +++ b/uninstall.php @@ -11,4 +11,32 @@ exit; } -delete_option( 'perflab_modules_settings' ); +// For a multisite, delete the option for all sites (however limited to 100 sites to avoid memory limit or timeout problems in large scale networks). +if ( is_multisite() ) { + + $site_ids = get_sites( + array( + 'fields' => 'ids', + 'number' => 100, + 'update_site_cache' => false, + 'update_site_meta_cache' => false, + ) + ); + + foreach ( $site_ids as $site_id ) { + switch_to_blog( $site_id ); + perflab_delete_plugin_option(); + } + restore_current_blog(); +} + +perflab_delete_plugin_option(); + +/** + * Delete the current site's option. + * + * @since n.e.x.t + */ +function perflab_delete_plugin_option() { + delete_option( 'perflab_modules_settings' ); +} From a3db3a324c8254cb973b24bb7b47a5d6b03a9ddc Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Wed, 10 Aug 2022 16:13:12 +0200 Subject: [PATCH 2/2] Fix sites loop and address final CR feedback. --- uninstall.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/uninstall.php b/uninstall.php index 908bfc57f3..89e2fac25f 100644 --- a/uninstall.php +++ b/uninstall.php @@ -13,7 +13,6 @@ // For a multisite, delete the option for all sites (however limited to 100 sites to avoid memory limit or timeout problems in large scale networks). if ( is_multisite() ) { - $site_ids = get_sites( array( 'fields' => 'ids', @@ -26,8 +25,8 @@ foreach ( $site_ids as $site_id ) { switch_to_blog( $site_id ); perflab_delete_plugin_option(); + restore_current_blog(); } - restore_current_blog(); } perflab_delete_plugin_option();