Skip to content

Fix updateSiteUrl() not taking effect on runtime: native-php imports - #4454

Open
fredrikekelund wants to merge 1 commit into
trunkfrom
stu-2197-fix-search-replace-on-import
Open

Fix updateSiteUrl() not taking effect on runtime: native-php imports#4454
fredrikekelund wants to merge 1 commit into
trunkfrom
stu-2197-fix-search-replace-on-import

Conversation

@fredrikekelund

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

I used Claude to iteratively reach the desired end state through an update-review-then-update workflow. I then used Codex to review the work.

Proposed Changes

STU-2197 revealed an underlying problem in BaseBackupImporter when used with native-php runtime sites: updateSiteUrl() did not work as expected. This was because WP-CLI could not connect to the database to run the wp option get and wp search-replace commands.

The Linear issue describes how this makes studio wp option get home return an unexpected result, but the consequences are actually much wider: all post_content URLs remain directed at the production site.

This PR fixes the problem by ensuring that BaseBackupImporter updates wp-config.php, installs the SQLite integration plugin, and installs all the Studio-specific mu-plugins. By the time updateSiteUrl() is called in importDatabase(), all the prerequisites for WP-CLI to work are now in place.

Testing Instructions

  1. npm start
  2. Add a new site
  3. Choose Connect a site and pull one of your remote sites
  4. Wait for the pull to finish
  5. Once finished, open the site directory in a terminal
  6. Run studio wp option get home
  7. Ensure that it returns the expected local URL (not the original production URL)

Pre-merge Checklist

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

@fredrikekelund
fredrikekelund requested review from a team and bcotrim August 5, 2026 11:56
@fredrikekelund fredrikekelund self-assigned this Aug 5, 2026
@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 1774dcd vs trunk

app-size

Metric trunk 1774dcd Diff Change
App Size (Mac) 1402.84 MB 1402.84 MB 0.00 MB ⚪ 0.0%

site-editor

Metric trunk 1774dcd Diff Change
load 1053 ms 1077 ms +24 ms ⚪ 0.0%

site-startup

Metric trunk 1774dcd Diff Change
siteCreation 7586 ms 7537 ms 49 ms ⚪ 0.0%
siteStartup 2888 ms 2875 ms 13 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@bcotrim bcotrim 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.

Approach looks right, and no regressions from the tests I ran.

I couldn't replicate the original issue on trunk though — pulled a remote site and wp option get home returned the local URL there too. Does the remote need particular conditions?

}
}

await installSqliteIntegration( site.path );

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.

Why not keepSqliteIntegrationUpdated here? The needsSqliteSetup guard exists for the MySQL workflow. Doesn't this reinstall SQLite over it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants