dbDelta issues w/ HyperDB
-
I’ve run into an issue where in certain situations, plugin database tables are not getting upgraded via the dbDelta function. The issue is that dbDelta runs
SHOW TABLES
and then loops through those tables. HyperDB seesSHOW TABLES
and doesn’t know how to extract the database from that query, so it uses the global database. That means dbDelta mistakenly thinks that the table does not exist, so it tries to create it instead of altering an existing table.I have managed to get around the problem by hacking
wp-admin/includes/upgrade.php
, but it’s not ideal. Basically, I’ve set it up to callSHOW TABLE STATUS LIKE '$table'
on each table in the$cqueries
array (rather than just oneSHOW TABLES
query), which means it’s slower. But I can’t really see another way around that. One implication of HyperDB is that any table could be on any server, so I think each table needs to be checked individually.I’m thinking about creating a ticket and a patch for WordPress, but before I go there I was hoping someone else might have run across this problem and have a better solution.
- The topic ‘dbDelta issues w/ HyperDB’ is closed to new replies.