Skip to content

Make DB_NAME constants removal logic language-agnostic#2822

Open
sejas wants to merge 2 commits intotrunkfrom
stu-1308-studio-make-the-removal-logic-for-db_name-constants-more
Open

Make DB_NAME constants removal logic language-agnostic#2822
sejas wants to merge 2 commits intotrunkfrom
stu-1308-studio-make-the-removal-logic-for-db_name-constants-more

Conversation

@sejas
Copy link
Member

@sejas sejas commented Mar 16, 2026

Related issues

How AI was used in this PR

Claude assisted with the regex implementation and test cases. All code was reviewed.

Proposed Changes

  • Replace exact string matching with a regex-based approach for removing default DB constants from wp-config.php
  • The regex is strict on PHP define() calls (only matches exact default values from wp-config-sample.php) but flexible with comments, so translated wp-config.php files are handled correctly
  • Add test cases for Polish, French, and comment-free wp-config.php files

Testing Instructions

  • Run npm start

  • Create a new site

  • Confirm wp-config.php doesn't have DB_* constants

  • In the same site, copy the content from wp-config-sample.php and paste it to wp-config.php, modify the any comment.

  • Go to the export tab and export the entire site.

  • Confirm the DB_* constants are removed.

  • In the same site, copy the content from wp-config-sample.php and paste it to wp-config.php, modify the any value.

  • Go to the export tab and export the entire site.

  • Confirm the all the DB_* constants are kept

  • Run npm test -- tools/common/lib/tests/remove-default-db-constants.test.ts

  • Verify all tests pass, including the new ones for translated comments

Pre-merge Checklist

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

Replace exact string matching with a regex that is strict on PHP
define() calls (only matches default values from wp-config-sample.php)
but flexible with comments, so translated wp-config.php files are
handled correctly.
@sejas sejas self-assigned this Mar 16, 2026
@sejas sejas marked this pull request as ready for review March 17, 2026 17:41
@sejas sejas requested a review from a team March 17, 2026 17:42
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