Add check for SQLite driver missing in target folder#2440
Conversation
packages/playground/cli/src/blueprints-v1/blueprints-v1-handler.ts
Outdated
Show resolved
Hide resolved
JanJakes
left a comment
There was a problem hiding this comment.
Looks good and works for me, thanks!
I only added a small idea about clarifying test descriptions a bit. Nothing critical.
| rmdirSync(tempDir, { recursive: true }); | ||
| }); | ||
|
|
||
| it('should not start WordPress without a working driver module', async () => { |
There was a problem hiding this comment.
Without taking a close look at the implementation, it's a bit hard for me to understand what each test case is doing. Maybe the messages could be a bit clearer?
My current understanding is something like this:
should not start WordPress without a working driver module
-> should not start WordPress when SQLite ZIP not specified and SQLite driver directory doesn't exist
should install WordPress with data but without specifying a driver module
-> should install WordPress when SQL data path specified, even without SQLite ZIP path or SQLite driver directory
should fail if the SQLite integration plugin is specified but not installed
-> should fail when the SQLite driver directory exists, but doesn't contain a valid driver
I may be wrong with some of these transcriptions; just wondering if we could make the messages super-clear.
| !options.sqliteIntegrationPluginZip && | ||
| !php.isDir(sqlitePluginPath) | ||
| ) { | ||
| throw new Error('SQLite integration plugin is not installed.'); |
There was a problem hiding this comment.
Playground CLI also supports MySQL sites so we can't assume that missing the SQLite plugin is always the error cause. We'll need to somehow decide what was the user intention.
There was a problem hiding this comment.
If SQLite is not installed, check if the current connection is not working by using $wpdb->check_connection() and why. If it's a problem of connection with a MySQL database (credentials, ping, etc.) generate a specific error. Otherwise the generic one.
There was a problem hiding this comment.
Sounds like a good direction! Perhaps we could always check the database connection, even when the SQLite plugin is installed — we always need a working database after all
There was a problem hiding this comment.
I agree! I will make sure to add this as soon as possible.
Co-authored-by: Adam Zieliński <adam@adamziel.com>
…tiple workers fail
…tiple workers fail
|
I've added a more granular check in case of WordPress installation failure and a non-working DB connection:
|
|
Thank you @zaerl! The logic looks pretty good and the test failures are unrelated to the code change. My only note is – the terms |
Yep, you're right. It's a typo. There, we check if the |
Motivation for the change, related issues
Context:
By running
npx @wp-playground/cli@latest server server --mount-before-install=.:/wordpress --skip-wordpress-setup --skip-sqlite-setupwithout:The CLI crashed. Now, more safety checks take into consideration:
--skip-sqlite-setup, it checks if the mu-plugins folder exists in the target folderImplementation details
Testing Instructions (or ideally a Blueprint)
Choose a working WordPress folder, such as a WordPress Studio one. It should work because the folder already has a sqlite driver inside:
This should not crash, but tell you that "SQLite installation has been skipped and no SQLite mu-plugin has been found".
This should work. Notice the
skip-sqlite-setupmissing:Other combinations should work as well.