Skip to content
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

Don't install SQLlite on server start when it wasn't installed already #176

Merged
merged 2 commits into from
May 28, 2024

Conversation

jeroenpf
Copy link
Contributor

@jeroenpf jeroenpf commented May 28, 2024

Related to https://github.com/Automattic/dotcom-forge/issues/7416

When a site is started (not created), we check if the currently installed version of the SQLite integration is outdated and then try to update it. In the case that the SQLite integration was not installed we only want to install it when there is no wp-config.php file present.

Proposed Changes

  • Check if the SQLite integration was installed before. If not, we don't try to install it.

Testing Instructions

  1. Download WordPress and create wp-config.php with settings for a local MySQL server.
    A quick way to run local MariaDB is by using docker with:
    docker run --name local-mariadb -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress_db -e MYSQL_USER=wp_user -e MYSQL_PASSWORD=wp_password -p 3306:3306 -d mariadb:latest
  2. Create site in Studio using the manually downloaded WordPress version
  3. Observe that the site uses MySQL and does not install SQLlite after creation.
  4. Turn off the site and start it again.
  5. Observe that the SQLite integration is not installed.
  6. Now stop the server, remove wp-config.php and start the server again.
  7. Observe that SQLite is now installed and your wp site is using the SQLite db.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@jeroenpf jeroenpf added [Type] Bug Something isn't working [Status] Needs Review labels May 28, 2024
@jeroenpf jeroenpf requested a review from a team May 28, 2024 08:37
@jeroenpf jeroenpf self-assigned this May 28, 2024
Copy link
Contributor

@kozer kozer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it and works as expected! Nice work Jeroen!!

2024-05-28T12:06:45,230510627+03:00

Copy link
Contributor

@kozer kozer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, I get the following error ( is happening in trunk as well ):

Error occurred in handler for 'createSite': Error: ENOENT: no such file or directory, copyfile '/home/wild/.config/Studio/server-files/sqlite-database-integration/db.copy' -> '/home/wild/Studio/my-true-website/wp-content/db.php'

Can you verify, this is not happening when you try to create a new site, by following the usual process?

@jeroenpf
Copy link
Contributor Author

For some reason, I get the following error ( is happening in trunk as well ):

Error occurred in handler for 'createSite': Error: ENOENT: no such file or directory, copyfile '/home/wild/.config/Studio/server-files/sqlite-database-integration/db.copy' -> '/home/wild/Studio/my-true-website/wp-content/db.php'

Can you verify, this is not happening when you try to create a new site, by following the usual process?

I am not seeing that error and creating a new site works without issues for me.

@kozer
Copy link
Contributor

kozer commented May 28, 2024

For some reason, I get the following error ( is happening in trunk as well ):

Error occurred in handler for 'createSite': Error: ENOENT: no such file or directory, copyfile '/home/wild/.config/Studio/server-files/sqlite-database-integration/db.copy' -> '/home/wild/Studio/my-true-website/wp-content/db.php'

Can you verify, this is not happening when you try to create a new site, by following the usual process?

I am not seeing that error and creating a new site works without issues for me.

It seems that deleting sqlite-integration folder from my ~/.config fix the issue.

Copy link
Contributor

@wojtekn wojtekn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeroenpf thanks, it works great. Nothing changes for users who follow standard Studio flows when creating, starting, stopping, and reading deleted sites, but flows with a custom MySQL database work well now.

@wojtekn wojtekn merged commit 7e62cfe into trunk May 28, 2024
12 checks passed
@wojtekn wojtekn deleted the fix/dont-install-sqlite-when-server-starts branch May 28, 2024 10:33
@dcalhoun
Copy link
Member

Thank you for addressing this oversight! 🙇🏻 I added automated tests in #179, as I believe this nuance could easily be overlooked in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants