Closed eddiesshop closed 3 weeks ago
@kariae during my local testing, I saw that the wp_links
table was empty. I think we typically don't consider this a crucial table that must be migrated correct?
If that's the case, then we should probably add one more change to this PR which ignores that table by default. Let me know what you think though.
I went ahead and added a new folder called Exceptions and a new class called CoreWPTableEmptyException. Then I went ahead and added some catches to where the validate_db_tables
function are called and checked if any of the tables are within an ignore list. If they are then execution are allowed to proceed. If any table is not within the ignore list, then a WP_CLI::error is displayed and execution is halted.
@iuravic I added those tables you indicated to the ignore list. So if an exception is thrown, it is caught, and if those tables are the reason for the exception, then they are ignored, and the content diff is allowed to continue.
Hey @iuravic! I ran PHPCS on the code that was modified. I've tested this fix with the content refresh that I was performing when this problem arose. Is there a particular site/setup you'd like me to test this with?
During a recent content diff, somehow the live wp_terms table (the table with new content that we're trying to merge into the current database) was empty. This caused the function recreate_categories to not function as expected. This is because when it tries to gather all the categories which must be brought over, it does a JOIN with this wp_terms table. But if that table is empty, the query will return no results, even though the wp_terms_taxonomy table has valid categories to be imported.
This function attempts to prevent that from happening in the first place, by checking if any core WP tables are empty before proceeding in earnest with the content diff.