site-kit-wp: Reset infinite loop
Bug Description
When trying to reset Site Kit either on the setup screen or via wp google-site-kit reset, nothing happens. It’s just stuck.
Steps to reproduce
- Try to reset Site Kit
- Wait forever
Additional Context
- PHP Version: 7.2
- Server: nginx, with Memcached object cache dropin
- Browser: Chrome on macOS
- Plugin Version 1.0.1
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- Ensure that reset and uninstall are working correctly, and optimize them to consume less memory & time.
Implementation Brief
- To ensure there are no side effects for uninstallation, let’s replace our uninstall hook with an
uninstall.phpfile. This file should then include the new reset/uninstall logic (see below), with the following condition at the top:if ( ! defined( WP_UNINSTALL_PLUGIN ) && empty( $googlesitekit_reset ) ) { return; } - Then, in the
Reset::all(), set a$googlesitekit_resetvariable totrueand require theuninstall.phpfile. - Instead of the other private methods in
Reset, theuninstall.phpfile should include simple and optimized DB queries using$wpdbwhich delete the data in a more efficient way:$wpdb->query( $wpdb->prepare( "DELETE * from {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s", $prefix, '_transient_' . $prefix, '_transient_timeout_' . $prefix ) )$wpdb->query( $wpdb->prepare( "DELETE * from {$wpdb->usermeta} WHERE meta_key LIKE %s", $user_prefix ) )- The
$prefixshould begooglesitekit_%and the$user_prefixshould be$context->is_network_mode() ? $prefix : $wpdb->get_blog_prefix() . $prefix. - To setup a
Contextclass instance (for the above check), the file should check if the class does not exist, and if so load the file manually. It can then create an instance of it.
- After the DB queries, the file should call
wp_cache_flush().
Changelog entry
- Fix reset and uninstall data removal by optimizing database queries.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (5 by maintainers)
Will do more testing this week. @swissspidy stop checking your work emails during your vacation 😉
On Sun, Nov 17, 2019 at 10:38 PM Pascal Birchler notifications@github.com wrote:
–
[image: Google Logo] Thierry Muller Developer Relations Program Manager Engineering - News & Content Ecosystem thierrymuller@google.com