Skip to content

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

Merged
wojtekn merged 2 commits into
trunkfrom
fix/dont-install-sqlite-when-server-starts
May 28, 2024
Merged

Don't install SQLlite on server start when it wasn't installed already#176
wojtekn merged 2 commits into
trunkfrom
fix/dont-install-sqlite-when-server-starts

Conversation

@jeroenpf

@jeroenpf jeroenpf commented May 28, 2024

Copy link
Copy Markdown
Contributor

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 requested a review from a team May 28, 2024 08:37
@jeroenpf jeroenpf self-assigned this May 28, 2024

@kozer kozer left a comment

Copy link
Copy Markdown
Contributor

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

@kozer kozer left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

kozer commented May 28, 2024

Copy link
Copy Markdown
Contributor

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.

@wojtekn wojtekn left a comment

Copy link
Copy Markdown
Contributor

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
@wojtekn
wojtekn deleted the fix/dont-install-sqlite-when-server-starts branch May 28, 2024 10:33
@dcalhoun

Copy link
Copy Markdown
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

None yet

4 participants