• Hello team,

    We have a problem. During upgrade of the plugin, the website will crash due to some ALTER table queries.

    Upon investigation, we can see that the plugin is checking if the Collation of every table is the default $wpdb->collate , yet it is setting it to: utf8mb4_general_ci which is not the default. The default returned by WordPress is: wp eval 'global $wpdb; echo $wpdb->collate;' utf8mb4_unicode_520_ci as you can imagine, this results in an endless loop of ALTER TABLE queries and eventually crashes the website.

    We first noticed this in the slow query log with entries such as this:
    Query   | 1373 | Waiting for table metadata lock | ALTER TABLE wp_statistics_visitor DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci ROW_FORMAT =  |         0 |             0 |

    The problem is in the plugin_upgrades method in file class-wp-statistics-install.php at the Change Charset All Table To New WordPress Collate section.

    To hotfix this problem, at every plugin update, we need to add a custom else in the check at the beginning of the function like this:

    // Check installed plugin version
    $installed_version = get_option('wp_statistics_plugin_version');
    if ($installed_version == WP_STATISTICS_VERSION) {
                return;
    } else {
    // update the option in database to the current version
    update_option('wp_statistics_plugin_version', WP_STATISTICS_VERSION);
    }

    We are looking forward for a permanent fix from your side.

    Please fix this, make the method use $wpdb->collate instead of hardcoding utf8mb4_general_ci.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Wrong collate during plugin update crashes site’ is closed to new replies.