Events gone after upgrading? Read this!
Posted on January 5, 2012
I’ve just discovered a potential bug in WordPress that may prevent some users from upgrading properly from version 4 to 5.
Who This Affects
If your database table names contain any capitals then chances are this affects you. If not, or if your events are showing up fine in the admin area, ignore this post, it is not affecting you!
You are upgrading from version 4 to version 5 and you notice that your events have disappeared. You check your database XX_em_events table and notice that there is no collumn called post_id, then your database did not upgrade.
Why is this happening?
Events Manager uses a function called dbDelta, which detects if you already have a database table installed and updates the structure accordingly or creates a new one if it doesn’t exist. dbDelta does not check for capitalized database names, it converts the names to lowercase, which on some systems with some server setups may return a false negative, meaning dbDelta tries to create a new database table and fails since it exists, so no upgrade takes place.
I have reported this bug to the WordPress ticket system and provided a solution there. Here it is again along with EM-specific upgrade instructions:
You firstly need to edit a WordPress core file which is /wp-admin/includes/upgrade.php line 1471 (do a search/replace if you don’t have line numbering in a text editor). Change this:
$cqueries[trim( strtolower($matches), '`' )] = $qry;
$cqueries[trim($matches, '`' )] = $qry;
Next, you should visit yourwordpresssite.com/wp-admin/options.php and find an input box named ‘dbem_version’, you should see a number greater than 5, set it to 4.9.
Finally, load up an EM admin page and wait whilst the upgrade goes through!