fix: remove help panel user meta (#51249)

This commit is contained in:
RJ 2024-09-13 05:46:27 +08:00 committed by Karol Manijak
parent 3f24f31bb2
commit 7906eaa71b
6 changed files with 57 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Removed the leftover user meta from the help panel spotlight

View File

@ -15,7 +15,6 @@ export type UserPreferences = {
dashboard_chart_type?: string;
dashboard_leaderboard_rows?: string;
dashboard_sections?: string;
help_panel_highlight_shown?: string;
homepage_layout?: string;
homepage_stats?: string;
orders_report_columns?: string;

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Removed the leftover user meta from the help panel spotlight

View File

@ -268,6 +268,7 @@ class WC_Install {
),
'9.4.0' => array(
'wc_update_940_add_phone_to_order_address_fts_index',
'wc_update_940_remove_help_panel_highlight_shown',
),
);

View File

@ -2872,3 +2872,51 @@ function wc_update_940_add_phone_to_order_address_fts_index(): void {
}
}
}
/**
* Remove user meta associated with the key 'woocommerce_admin_help_panel_highlight_shown'.
*
* This key is no longer needed since the help panel spotlight tour has been removed.
*
* @return void
*/
function wc_update_940_remove_help_panel_highlight_shown() {
global $wpdb;
$meta_key = 'woocommerce_admin_help_panel_highlight_shown';
$deletions = $wpdb->query(
$wpdb->prepare(
"DELETE FROM $wpdb->usermeta WHERE meta_key = %s",
$meta_key
)
);
// Get the WooCommerce logger to track the results of the deletion.
$logger = wc_get_logger();
if ( null === $logger ) {
return;
}
if ( false === $deletions ) {
$logger->notice(
'During the update to 9.4.0, WooCommerce attempted to remove user meta with the key "woocommerce_admin_help_panel_highlight_shown", but was unable to do so.',
array(
'source' => 'wc-updater',
)
);
} else {
$logger->info(
sprintf(
1 === $deletions
? 'During the update to 9.4.0, WooCommerce removed %d user meta row associated with the meta key "woocommerce_admin_help_panel_highlight_shown".'
: 'During the update to 9.4.0, WooCommerce removed %d user meta rows associated with the meta key "woocommerce_admin_help_panel_highlight_shown".',
number_format_i18n( $deletions )
),
array(
'source' => 'wc-updater',
)
);
}
}

View File

@ -166,7 +166,6 @@ class Homescreen {
'homepage_layout',
'homepage_stats',
'task_list_tracked_started_tasks',
'help_panel_highlight_shown',
)
);
}