-
Notifications
You must be signed in to change notification settings - Fork 800
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
CRM: 3406 - address SQLite table creation error #34872
CRM: 3406 - address SQLite table creation error #34872
Conversation
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. |
What steps / what kind of testing site did you use to be able to do this? I've tried with Jurassic Ninja sites - results in the following error: Local (by Flywheel) sites - activating the plugin just results in an error saying that 'The SQLite Integration plugin is active, but the SQLite3 class is missing from your server. Please make sure that SQLite is enabled in your PHP installation.'. Then on a Pressable site, which just resulted in a critical error. |
Jurassic Ninja seems to have more general issues with SQLite prior to even getting to our plugin; probably a custom setup preventing WP from installing.
Odd; I didn't have any issues...what version of PHP?
What was the error there? |
Noting here that we sorted out the SQLite issues - updating my Local site to use PHP 8.0+ helped. I did test this in two different environments though and both times I am still seeing 'Jetpack CRM experienced errors' message on the system status page. The first environment is the Local test site, testing first on trunk and then using the branch. Then secondly directly in WP playground, initially testing trunk then the branch. However in the third scenario it did work - directly creating a WP playground site and going straight to the branch. Having trunk active beforehand seemed to cause the error to stay. Is this expected? |
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.
Thinking about this more, it really doesn't matter what happens in trunk before using this branch, as once this is merged the playground is only ever going to use the new code. So 👍 from me.
Yes, if you go from |
* Add database engine check * Add changelog * CRM: 3406 - address SQLite table creation error (#34872) * Remove obsolete database table * Bypass InnoDB check for SQLite * Add changelog * CRM: 3404 - address syntax differences between SQLite and MySQL (#34869) * Update table alias The `transaction` alias is a reserved keyword in SQLite. * Implement engine-agnostic build_group_concat() * Add changelog
Resolves Automattic/zero-bs-crm#3406 - address SQLite table creation error
Proposed changes:
If using SQLite, the System Status page (
/wp-admin/admin.php?page=zerobscrm-systemstatus&tab=status
) will show a notice that there were issues creating database tables.This addresses the above by short-circuiting the InnoDB check if using SQLite, as we already know SQLite has no InnoDB support and the
SHOW ENGINES
query used is not valid in SQLite.This was a bit complicated, as it was supposed to output the errors but they were always blank. Digging around, I learned that if a database query was determined to be invalid prior to running, it just returns
false
rather than actually running and providing the error. In this case, it seems it was becauseSHOW ENGINES
was not deemed valid.While investigating the cause, I managed to trigger some errors around a
zbscrm_api_keys
table; this was probably incidental because it was the first table created, but said table is never actually used other than hard-coded checks for its existence (don't ask me why), so I removed code related to its creation and detection. Removing it from existing installs is out of scope here.Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
The most painless way to do this is to set up SQLite via the SQLite Database Integration plugin. Install that on a WordPress site, initialise the site, and then you should be good to go.
Go to the System Status page:
/wp-admin/admin.php?page=zerobscrm-systemstatus&tab=status
In
trunk
, you'll see this message:In the
fix/crm/3406-address_sqlite_table_creation_error
branch, the error is no more.