-
Notifications
You must be signed in to change notification settings - Fork 22
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
Studio: Fix site url after import #437
Conversation
I left two comments and I didn't test it yet. Props for the clean solution! |
@kozer I'm curious about why changes from Sqlite: Fix LIKE BINARY queries are required to test the PR. What's the connection between rewriting the site URL and that fix? |
Hey @fluiddot!
|
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.
I explored the database after importing a Jetpack backup and I still see references to the original site URL. Specifically, in the guid
column of the wp_posts
table. Similarly, when I export the database, I see in the SQL file references to the original site URL. Not sure if I'm testing it incorrectly, @kozer are you getting different results?
No @fluiddot , you are right on that! I suspect that this is due to what I'm referring to in the description.
Note that I have tried |
That's interesting. After further exploring the database, I find that the options Curiously enough, the output of the WP-CLI command
@kozer have you been able to identify any of those replacements? What do we expect to replace when executing the function |
For me those URLs get replaced... It's strange.
Yes, the URLs in
I'm not sure what portion of URLs gets replaced. I guess it's in the internals of |
@fluiddot , I did a longer investigation. First of all, what I used the following process:
Before import grep 'localhost:8891' studio-backup-my-serene-website-2024-08-08-14-46-25.sql | wc -l
7 This included links in After import - before fix grep 'localhost:8891' studio-backup-my-serene-website-2024-08-08-14-46-25_2.sql | wc -l
0 All URLs were replaced, After import - after fix grep 'localhost:8891' studio-backup-my-serene-website-2024-08-08-14-46-25_3.sql | wc -l
2 This is correct as:
|
Thank you so much @kozer for investigating this 🙇 ! I think the problem I was having was related to not applying the changes to the SQLite integration (ref). I tried again and now I can see some of the replacements.
Seems that
|
Co-authored-by: Carlos Garcia <[email protected]>
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.
@kozer Regarding the changes from WordPress/sqlite-database-integration#149, should we hold the merge of this PR until a new version of sqlite-database-integration
is released with the needed changes?
- Open the .sql file, and search for baseurl. Ensure it's the URL of your local site.
The testing instructions mention baseurl
but I wonder if we should check siteurl
(in wp_options
table) instead. If so, I confirmed it changes this value to the proper site URL.
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.
Not a blocker for this PR but it would be great if we could cover this functionality with unit tests.
@fluiddot , we can wait, although it's not mandatory. |
It's true that the only side-effect of not including the fix is that the rewrite isn't happening. Apart from that, it won't produce any errors, so it sounds good to me to merge it as-is. We could add a note to the associated GitHub issue explaining that the issue is pending to be solved upon merging WordPress/sqlite-database-integration#149. WDYT? |
@kozer, I've noticed this will fail for new sites. I've tried running the importDatabase after the importWpContent, but it's still displaying an error message int he console. Do you have any ideas how to fix it? This line "const { stdout: currentSiteUrl } = await server.executeWpCliCommand( UPDATE: The import works, but probably the search-replace do not, because the wp-content files and sqlite database integration are not ready. Steps to reproduce:
|
On it! I ll check it out. Thanks for mentioning! |
As discussed, #455 solves the above issue |
Related to https://github.com/Automattic/dotcom-forge/issues/8462
Proposed Changes
After import, the URLs are pointing to the old site, and not to the URL used by studio.
This pr fixes that, by replacing the URLs in the database.
Relation with sqlite PR
wp search-replace
among other queries, it runsLIKE REPLACE
queries as well ( I manage to make it do that after adding DROP table if exists in each sql file of a jetpack backup and try to import that ).~/Studio/< a site>
and runwp search-replace
.Testing Instructions
wp-content/mu-plugins/sqlite-database-integration/
, and ensure that you apply the changes under this pr in your local plugin.STUDIO_IMPORT_EXPORT=true
flag..sql
file, and search forbaseurl
and/orsiteurl
. Ensure it's the URL of your local site.NOTE: Some URLs are not getting updated, but this is normal, as stated under this issue.
Pre-merge Checklist