Skip to content

Fix wp_site.domain in db-pull multisite fixup - #234

Merged
jasperf merged 3 commits into
mainfrom
fix/db-pull-multisite-wp-site-domain
Sep 16, 2026
Merged

jasperf merged 3 commits into
mainfrom
fix/db-pull-multisite-wp-site-domain

Conversation

@jasperf

@jasperf jasperf commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

db-pull --multisite rewrote wp_blogs.domain but not wp_site.domain, so a pulled multisite network came back half-rewritten.

Both columns store a bare hostname, which is why the multisite fixup exists in the first place — the ordinary search-replace looks for a scheme-prefixed URL (https://example.comhttp://example.test) and never matches either column. The fixup covered the subsites and left the network row alone.

The result: every subsite on the development host, and the network itself still claiming the production domain, disagreeing with DOMAIN_CURRENT_SITE in the local config. The front end still renders, which is what makes it easy to miss — it surfaces later as network-admin URLs and redirects built from the production host.

Found on demo.imagewize.com (9 subsites) after a --multisite pull:

wp_blogs.domain  →  demo.imagewize.test   ✓ (all 9)
wp_site.domain   →  demo.imagewize.com    ✗ production value

Changes

  • scripts/backup/db-pull.sh — the multisite step now runs a second UPDATE against wp_site, alongside the existing wp_blogs one. Step label updated to "Fixing multisite network and blog domains".
  • mcp-server/src/tools/dbPull.ts — same fix for the db_pull MCP tool; both statements go through one wp db query call.
  • mcp-server/src/server.tsmultisite flag description updated.
  • CHANGELOG.md — 5.24.1.

wp_sitemeta.siteurl needed no change — it holds a full scheme-prefixed URL, so the ordinary search-replace already reaches it. Verified on the same network.

Scope

Single-site pulls are untouched: without --multisite, neither statement runs. The new UPDATE uses the same wp_ table prefix the existing code already assumed.

Verification

  • bash -n scripts/backup/db-pull.sh — clean.
  • npx tsc --noEmit in mcp-server/ — clean.
  • Ran the combined two-statement query against the local demo.imagewize.com network: wp db query accepts both in one call, and re-running it reports Rows affected: 0 — the fixup is idempotent.

@jasperf
jasperf merged commit 02c8fa0 into main Sep 16, 2026
1 check passed
@jasperf
jasperf deleted the fix/db-pull-multisite-wp-site-domain branch September 16, 2026 06:32
jasperf added a commit that referenced this pull request Sep 19, 2026
siteurl and home diverge on Bedrock (siteurl carries the /wp core
subdirectory, home doesn't), but db-pull's search-replace was built
from siteurl alone. Content — nav menus, post guids, the home option
itself — is written against home, never siteurl, so the replace
matched nothing there, exited 0, and the pulled site looked fine
until someone clicked a menu link and landed back on production.

Found on demo.imagewize.com after a --multisite pull: every subsite's
block-based Navigation menu, and several post guids, still pointed at
https://demo.imagewize.com/... even though wp_blogs.domain/
wp_site.domain (the #234 fix) were both already correct — this is a
separate gap from that one.

Both db-pull.sh and the db_pull MCP tool now read home for prod and
dev alongside siteurl, and run a second search-replace pass against
the home pair whenever it differs from the siteurl pair (always, on
Bedrock; skipped on non-Bedrock installs where siteurl === home).

A third pass replaces the http:// form of prod's home when prod is on
https://. Content written before a site moved to HTTPS still links to
http://example.com/..., which neither of the other passes matches —
the manual fix on demo.imagewize.com needed both variants.
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.

1 participant