New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: logic func which will throw exception if core WP tables are empty. #330
base: trunk
Are you sure you want to change the base?
feat: logic func which will throw exception if core WP tables are empty. #330
Conversation
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.
@kariae during my local testing, I saw that the 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. |
…ditional handling of which Core WP tables can be safely ignored.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eddiesshop as I shared during our Sprint, I think we should hardcode that some core tables are expected to possibly be empty not to break automatic execution of content refresh via Knife.
I've created a blank Atomic site and the following tables can be empty:
wp_commentmeta wp_comments wp_links wp_termmeta
Can you please add this?
Adding wp_termmeta, wp_comments, and wp_commentmeta to list of default ignored tables.
@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.