Skip to content

Fix site export in offline mode - #2481

Merged
bcotrim merged 3 commits into
trunkfrom
stu-1258-ensure-site-export-works-offline
Jan 27, 2026
Merged

Fix site export in offline mode#2481
bcotrim merged 3 commits into
trunkfrom
stu-1258-ensure-site-export-works-offline

Conversation

@bcotrim

@bcotrim bcotrim commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

Related issues

Proposed Changes

  • Fix sqlite export command to use absolute path /wordpress/<filename> instead of relative path. The WASM filesystem mounts the site at /wordpress but PHP's working directory isn't set there, causing relative paths to fail. This is the same fix applied to sqlite import in PR Fix backup import for Jetpack, Local, Wpress and Studio formats #2422.
  • Fix getSitePlugins and getSiteThemes to tolerate stderr warnings when stdout contains valid JSON. When offline, WordPress produces warnings about being unable to connect to WordPress.org for update checks, but the plugin/theme list commands still return valid data.

Testing Instructions

  1. Create a site in Studio and start it
  2. Disconnect from the internet
  3. Export the site using "Export site" option
  4. Verify the export completes successfully without errors
  5. Reconnect to the internet
  6. Export the site again to verify it still works when online
  7. (Optional) Import the exported backup to verify it's valid

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@bcotrim bcotrim self-assigned this Jan 27, 2026
@bcotrim
bcotrim requested a review from a team January 27, 2026 11:02
let loggerReportSuccessSpy: jest.SpyInstance;
let loggerReportWarningSpy: jest.SpyInstance;

const createPathExistsMock = ( sitePathExists = false ) => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unrelated change to fix npm run lint warning.

@wpmobilebot

wpmobilebot commented Jan 27, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing f798c84 vs trunk

site-editor

Metric trunk f798c84 Diff Change
load 2891.00 ms 3000.00 ms +109.00 ms 🔴 3.8%

site-startup

Metric trunk f798c84 Diff Change
siteCreation 8068.00 ms 8097.00 ms +29.00 ms 🔴 0.4%
siteStartup 3935.00 ms 3922.00 ms -13.00 ms 🟢 -0.3%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@ivan-ottinger ivan-ottinger 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.

Thank you for the fix, Bernardo! The changes look good and I can confirm they resolve the issue. Export now works well while being offline.

Image

I did not observe any regressions - online export still runs as before. Import as well. 👍🏼

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

Thanks @bcotrim for fixing this! I have tested it, and it works as expected, I am able to export site in offline mode while I can reproduce the error in trunk. I have left a question out of curiosity, but changes LGTM!

Image
);
}

// Try to parse the output first - WordPress may produce warnings on stderr

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.

Parsing the output first makes sense 👍

One question about the code is that we are parsing stdout, but the comment mentions WordPress may produce warnings on stderr, should that be stdout in the comment 🤔 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I updated the comment in f798c84
Let me know if it's clear now 🙏

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.

That's much clearer now, and it makes total sense, thanks for updating!

@gcsecsey gcsecsey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix @bcotrim! These changes LGTM, I tested them on Windows to make sure the path updates work there too. I confirm being able to export and reimport sites without issues now. 👍

CleanShot.2026-01-27.at.12.10.47.mp4
@bcotrim
bcotrim merged commit b8958c6 into trunk Jan 27, 2026
11 checks passed
@bcotrim
bcotrim deleted the stu-1258-ensure-site-export-works-offline branch January 27, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants