WordPress.org

Make WordPress Core

Opened 7 weeks ago

Closed 7 weeks ago

Last modified 7 weeks ago

#49460 closed enhancement (fixed)

wp-config gets cleaned out from build folder on rebuild

Reported by: isabel_brison Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version: 5.4
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

If there is a wp-config.php file in the build folder, it gets cleaned out when npm run build is run.

This has become a problem because the newest version of @wordpress/env allows us to setup a unified core/gutenberg development environment from the build folder of our local wordpress-develop. In doing so, it writes a wp-config.php to that folder, which gets wiped out on running npm run build, destroying the development environment.

In testing a fix for this issue, I came across an existing bug in the clean:files task: because BUILD_DIR gets prepended to the strings in the buildFiles array, if any of those strings is a negation, it won't work because the ! will now be in the middle of the string, instead of at the start.

I'm adding a patch for both the main issue and the bug.

Attachments (2)

49460.diff (776 bytes) - added by isabel_brison 7 weeks ago.
49460.2.diff (869 bytes) - added by SergeyBiryukov 7 weeks ago.

Download all attachments as: .zip

Change History (10)

@isabel_brison
7 weeks ago

#1 @isabel_brison
7 weeks ago

  • Keywords has-patch added

#2 in reply to: ↑ description @SergeyBiryukov
7 weeks ago

  • Milestone changed from Awaiting Review to 5.4

Replying to isabel_brison:

If there is a wp-config.php file in the build folder, it gets cleaned out when npm run build is run.

Just noting that wp-config.php can be put one level above the build folder, that way it doesn't get cleaned out but still gets recognized by WordPress.

That said, I guess it makes sense to preserve it in the build folder if it's there.

#3 @SergeyBiryukov
7 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 47303:

Build/Test Tools: Keep wp-config.php file in the build directory on rebuild.

Props isabel_brison.
Fixes #49460.

#4 @afercia
7 weeks ago

To my understanding, this means that from now on any edit to wp-config.php in the src directory won't be copied over the build directory any longer. Not sure it's ideal for the ones of us that run WordPress from build as it will require to manually edit build/wp-config.php while working on src.

#5 @SergeyBiryukov
7 weeks ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Replying to afercia:

To my understanding, this means that from now on any edit to wp-config.php in the src directory won't be copied over the build directory any longer. Not sure it's ideal for the ones of us that run WordPress from build as it will require to manually edit build/wp-config.php while working on src.

Wouldn't placing the file one level above build and src resolve this?

As an alternative, we could preserve the file if it exists in build, but still copy it over from src if it also exists there. 49460.2.diff should do that.

#6 @isabel_brison
7 weeks ago

As an alternative, we could preserve the file if it exists in build, but still copy it over from src if it also exists there. 49460.2.diff​ should do that.

Thanks @SergeyBiryukov, this seems to me the best way forward!

It's the solution most compatible with @wordpress/env, which adds wp-config in the root of the WP instance it's running from. This is because @wordpress/env can be configured to run not only from build or src but from any tag or version of development or production WP, so we can't assume a particular folder structure.

#7 @SergeyBiryukov
7 weeks ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 47312:

Build/Test Tools: Keep wp-config.php file in the build directory on rebuild, but still copy it over from src if it also exists there.

Follow-up to [47303].

Props afercia, isabel_brison, SergeyBiryukov.
Fixes #49460.

#8 @isabel_brison
7 weeks ago

Props afercia, isabel_brison, SergeyBiryukov.

Also props to @noisysocks for helping me debug the issue!

Note: See TracTickets for help on using tickets.