Bug #21551
openFinding plugins that loop through all network sites
0%
Description
As part of our ongoing database woes, I noticed in our slow query logs that something is doing the following:
SELECT blog_id FROM wp_blogs
This query itself is pretty slow, but what worries me is what comes next.
I ran a couple of greps across our codebase to see which plugins are doing this kind of thing. Many are, but most of them are part of an uninstall method (uninstall.php, uninstall hooks, etc) that should never be run on the Commons. For the remaining items, I'd like to do a bit of investigation and remediation. I'll use this ticket to track that work.
Updated by Boone Gorges 3 days ago
I put a bit of a honeypot in place (in the form of a 'query' callback) to get stack traces, and I found many instances of the following:
[2024-11-21 22:12:55] shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, S2_Upgrade->upgrade, S2_Upgrade->upgrade6_4, S2_Multisite->namechange_subscribe2_widget, wpdb->get_col, wpdb->query, apply_filters('query'), WP_Hook->apply_filters, {closure} [2024-11-21 22:12:57] shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, S2_Upgrade->upgrade, S2_Upgrade->upgrade6_4, S2_Multisite->namechange_subscribe2_widget, wpdb->get_col, wpdb->query, apply_filters('query'), WP_Hook->apply_filters, WP_CLI\Runner->{closure} [2024-11-21 22:13:11] shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, S2_Upgrade->upgrade, S2_Upgrade->upgrade6_4, S2_Multisite->namechange_subscribe2_widget, wpdb->get_col, wpdb->query, apply_filters('query'), WP_Hook->apply_filters, {closure} [2024-11-21 22:13:48] shutdown_action_hook, do_action('shutdown'), WP_Hook->do_action, WP_Hook->apply_filters, S2_Upgrade->upgrade, S2_Upgrade->upgrade6_4, S2_Multisite->namechange_subscribe2_widget, wpdb->get_col, wpdb->query, apply_filters('query'), WP_Hook->apply_filters, {closure}
What the subscribe2 plugin is trying to do here is kinda dumb, and the fact that they run it on a shutdown hook that indiscriminately runs across the network is very bad. I've put a fix in place that prevents this particular part of the plugin upgrade routine from running: https://github.com/cuny-academic-commons/cac/commit/17f727212d34ede4c67aed2c4ab78c367d82515c This has been deployed immediately, in the chances that it's related to recent outages.