[wp-trac] [WordPress Trac] #53480: Existing config files lost when installing local-env

WordPress Trac noreply at wordpress.org
Tue Jun 22 17:25:48 UTC 2021


#53480: Existing config files lost when installing local-env
------------------------------+-----------------------------
 Reporter:  iandunn           |      Owner:  (none)
     Type:  enhancement       |     Status:  new
 Priority:  low               |  Milestone:  Awaiting Review
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 === Problem

 `npm run env:install` overwrites existing `wp-config.php` and `wp-tests-
 config.php` files without warning. Those files aren't versioned, so they
 have to be restored from a local backup, if one exists.

 That makes sense in hindsight, but it wasn't obvious to me before running
 the command.

 I normally use a local nginx/php/mysql stack (via homebrew), but the unit
 tests don't work locally because I'm running PHP 8 (#46149), so I wanted
 to use local-env to run the tests. Running the install broke my normal
 environment, but luckily I had a backup.

 Even if someone is only using local-env, they may have changes they want
 to preserve between installs. e.g., if they re-install to try and fix
 something that's not working.


 === Potential solution: manual intervention

 One approach would be to remove the `--force` param when creating `wp-
 config.php`, so WP-CLI errors out. Folks could then manually backup/remove
 the file and run the command again.

 For `wp-tests-config.php`, the install script could check if the file
 exists before creating it, and abort with a warning if it does.

 That won't affect contributors installing for the first time.

 === Potential solution: automatic backups

 To avoid manual intervention, another approach would be to rename existing
 files to `wp-config.php.backup1`, `wp-config.php.backup2`, so that each
 version is preserved.

 === Potential solution: prompt before running

 A simpler solution might be to just print a warning to the console at the
 start of the script, and prompt the user to continue. That'd introduce
 unnecessary friction for new contributors, though.

 At the very least, though, I think there should be a warning in the
 `README`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53480>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list