Skip to content

Preserve external MySQL database names - #4690

Open
atirna wants to merge 4 commits into
Automattic:trunkfrom
atirna:fix/preserve-external-mysql-db-name
Open

atirna wants to merge 4 commits into
Automattic:trunkfrom
atirna:fix/preserve-external-mysql-db-name

Conversation

@atirna

@atirna atirna commented Aug 26, 2026 •

Copy link
Copy Markdown

Related issues

How AI was used in this PR

Used AI assistance while investigating and implementing this fix. I reviewed and own the patch.

Proposed Changes

  • Uses the site's SQLite integration state to decide whether Studio owns DB_NAME.
  • Sets DB_NAME to wordpress for SQLite sites, including empty, dynamic, or duplicate definitions.
  • Leaves all DB_NAME definitions untouched for external MySQL sites.

Testing Instructions

  • npm test -- apps/cli/lib/native-php/tests/site-setup.test.ts (10 passed)
  • npx prettier --check apps/cli/lib/native-php/site-setup.ts apps/cli/lib/native-php/tests/site-setup.test.ts apps/cli/lib/import-export/import/importers/importer.ts
  • npx eslint apps/cli/lib/native-php/site-setup.ts apps/cli/lib/native-php/tests/site-setup.test.ts apps/cli/lib/import-export/import/importers/importer.ts apps/cli/php/wp-config-transformer.php
  • php -l apps/cli/php/wp-config-transformer.php

Pre-merge Checklist

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

Comment thread apps/cli/lib/native-php/site-setup.ts Outdated
Comment thread apps/cli/php/wp-config-transformer.php Outdated

@gavande1 gavande1 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 @atirna for opening this and for digging into the root cause. I have left a few comments inline, mostly around the edge cases for the preserved value.

@gavande1

Copy link
Copy Markdown
Contributor

Thanks, @atirna, for addressing the feedback. I will take a look shortly.

@gavande1

gavande1 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@wojtekn, do you have a few minutes to take a look at this one too? Would love your eyes on it.

Comment thread apps/cli/lib/native-php/site-setup.ts Outdated
@atirna

atirna commented Sep 16, 2026

Copy link
Copy Markdown
Author

good call, done. building it conditionally keeps the object literal typed, so WP_DEBUG_LOG/WP_DEBUG_DISPLAY stay boolean instead of widening to boolean | string for the sake of the delete.

DEFAULT_WP_CONFIG_CONSTANTS only holds DB_NAME, so spreading it conditionally is exactly what the delete was doing, no behaviour change. npx tsc -p apps/cli/tsconfig.json --noEmit is clean.

constant_exists, constant_equals and define_constant each walked the
token array looking for the same call.
…type

Spreading the defaults and deleting DB_NAME afterwards required a
Record<string, boolean | string>, which dropped the compile-time check that
WP_DEBUG_LOG and WP_DEBUG_DISPLAY stay boolean.
@atirna
atirna force-pushed the fix/preserve-external-mysql-db-name branch from 51bb9c1 to 4a1e472 Compare September 17, 2026 02:55
@MCharretier

Copy link
Copy Markdown

Hi @gavande1 — any news on this one ? The last review comment looks addressed. Is there a chance it lands in 1.23 ?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native PHP runtime forces external MySQL database name to wordpress

3 participants