Disable import/export for sites not using SQLite integration - #463
Conversation
|
@matt-west let me know if you could take a look at the UI and share thoughts/feedback. I decided to use the WordPress Notice component as an initial iteration, but we could follow a better approach. Thanks 🙇 ! |
| ); | ||
| const wpConfigPath = nodePath.join( this.details.path, 'wp-config.php' ); | ||
| const databaseIndexPath = nodePath.join( this.details.path, 'wp-content', 'db.php' ); | ||
| const databasePath = nodePath.join( this.details.path, 'wp-content', 'database', '.ht.sqlite' ); |
There was a problem hiding this comment.
I don't think we need to check this because even if you remove this file, the site will still work and use SQLite. It will just create a new .ht.sqlite file automatically.
There was a problem hiding this comment.
Ah, thanks for pointing this out. I've tested removing the file and confirmed it's recreated. Hence, I'll remove this check.
| } | ||
| } | ||
|
|
||
| async isSQLiteInstalled(): Promise< boolean > { |
There was a problem hiding this comment.
Is this function checking if SQLite plugin is installed or if it is active? I think, based on the code inside the function, that it is to check if SQLite is active. If that is the case, for clarity maybe this can be renamed to isSQLitePluginActivated or something similar.
There was a problem hiding this comment.
Yep, good point. The function checks both that is installed and active. My rationale is that since the SQLite plugin is a must-use plugin if it's installed we also consider it active. However, I agree that it's more accurate to reference in the function's name that the plugin is active. I'll rename it.
|
@fluiddot Sorry for the slow response on this! Using the Notice component here makes sense. We’ll have an updated version of this in the new design system, but we can use this one for now. I think we could tweak the copy to something like:
|
Great, thanks @matt-west for taking a look 🙇 ! I'll update the message and wrap up the PR with the current design 👍 . |
f0a508c to
792b39e
Compare
|
@jeroenpf @matt-west I've addressed the latest comments and updated the message in the notice. The PR is now ready to review. Thanks 🙇 ! |
|
@fluiddot it works for most of my sites. However, it disables Import / Export for some older sites that had Could we handle those, too? |
Sure, I'll cover this case when we use |
|
@wojtekn, I wonder how is possible to have a site with the old integration 🤔 . From what I can see the old/main SQLite folder gets renamed when the site starts. studio/src/lib/sqlite-versions.ts Line 173 in 792b39e studio/src/lib/sqlite-versions.ts Lines 139 to 142 in 792b39e Could you share your zip? Maybe your site is using MySQL? |
|
@sejas I checked two sites, and one has a plugin in The sites that show the warning, have the plugin in |
…-import-export-mysql-sites
|
@wojtekn , can you try again? I tried using a different approach, by checking if the $wpdb uses the SQLite PHP class, but I had to go back to use the paths check because my approach only worked for started sites. Making it work for stopped sites is possible but we need a big refactor, and I think that is currently out of scope of this issue. Here is the code for reference to check if SQLite is used in a WordPress site: So in the end I just added the alternative paths and added a new test. Let me know if it works for your old sites. |
wojtekn
left a comment
There was a problem hiding this comment.
Works well for all three cases: plugin in wp-content/, plugin in mu-plugins/, and plugin in mu-plugins/ with -main appended to the name.
| } | ||
| } | ||
|
|
||
| async isSQLitePluginActivated(): Promise< boolean > { |
There was a problem hiding this comment.
As we only check if files and directories exist, should we find a more accurate name for the function like hasSQLitePlugin?


Related to https://github.com/Automattic/dotcom-forge/issues/9395
Proposed Changes
Testing Instructions
wp-content/db.php.Pre-merge Checklist