Fix migrateEnvFile overwriting existing .env.local during retried flex migration#19
Merged
Merged
Conversation
When the flex migration template step is retried (e.g., after a partial failure where symfony.lock wasn't created), migrateEnvFile() would be called again. On the second call, .env contained defaults (from the first migration) and .env.local contained the real DATABASE_URL (renamed from original .env). The rename() call would overwrite .env.local with the default content from .env, losing the user's real DATABASE_URL. Fix: Add a guard to skip the rename if .env.local already exists, preserving any existing configuration in .env.local." Agent-Logs-Url: https://github.com/shopware/web-installer/sessions/27549929-0551-46e2-b276-d1fddc3e85f2 Co-authored-by: shyim <6224096+shyim@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix web installer to respect existing DATABASE_URL configuration
Fix migrateEnvFile overwriting existing .env.local during retried flex migration
May 14, 2026
|
Copilot misunderstood the issue. There was no .env.local file in the installation. The DATABASE_URL was only defined in the .env file. This file was overwritten by the update process. The updater did not create a .env.local file. |
Member
|
the git diff looks correct. if a |
|
I just read the subject and the description above. The git diff looks correct. Thanks. |
Soner (shyim)
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a non-flex → flex migration partially fails (before
symfony.lockis created), retrying causesmigrateEnvFile()to be called again. On the second call,rename('.env', '.env.local')silently overwrites the.env.localthat was created by the first run — which held the user's realDATABASE_URL— with the stale default content now in.env, permanently destroying the original database configuration.Changes
Services/FlexMigrator.php: Guard the rename with an existence check on.env.local. If it already exists, skip the rename and only (re)write the default template to.env. This makes the migration idempotent.Tests/Services/FlexMigratorTest.php: AddtestMigrateEnvDoesNotOverwriteExistingEnvLocal()covering the case where.env.localis already present whenmigrateEnvFile()is called.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7787ceff91365ba7d623ec410b8f429cdebb4f63REDACTED, pid is -1(http block)https://api.github.com/repos/Seldaek/jsonlint/zipball/1748aaf847fc731cfad7725aec413ee46f0cc3a2REDACTED, pid is -1(http block)https://api.github.com/repos/Seldaek/phar-utils/zipball/ea2f4014f163c1be4c601b9b7bd6af81ba8d701cREDACTED, pid is -1(http block)https://api.github.com/repos/Seldaek/signal-handler/zipball/04a6112e883ad76c0ada8e4a9f7520bbfdb6bb98REDACTED, pid is -1(http block)https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0REDACTED, pid is -1(http block)https://api.github.com/repos/composer/ca-bundle/zipball/961a5e4056dd2e4a2eedcac7576075947c28bf63REDACTED, pid is -1(http block)https://api.github.com/repos/composer/class-map-generator/zipball/8f5fa3cc214230e71f54924bd0197a3bcc705eb1REDACTED, pid is -1(http block)https://api.github.com/repos/composer/composer/zipball/72a8f8e653710e18d83e5dd531eb5a71fc3223e6REDACTED, pid is -1(http block)https://api.github.com/repos/composer/metadata-minifier/zipball/c549d23829536f0d0e984aaabbf02af91f443207REDACTED, pid is -1(http block)https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21eREDACTED, pid is -1(http block)https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95REDACTED, pid is -1(http block)https://api.github.com/repos/composer/spdx-licenses/zipball/edf364cefe8c43501e21e88110aac10b284c3c9fREDACTED, pid is -1(http block)https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85efREDACTED, pid is -1(http block)https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbcREDACTED, pid is -1(http block)https://api.github.com/repos/jsonrainbow/json-schema/zipball/6fea66c7204683af437864e7c4e7abf383d14bc0REDACTED, pid is -1(http block)https://api.github.com/repos/marc-mabe/php-enum/zipball/bb426fcdd65c60fb3638ef741e8782508fda7eefREDACTED, pid is -1(http block)https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6aREDACTED, pid is -1(http block)https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82REDACTED, pid is -1(http block)https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176REDACTED, pid is -1(http block)https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74REDACTED, pid is -1(http block)https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bfREDACTED, pid is -1(http block)https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963REDACTED, pid is -1(http block)https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0REDACTED, pid is -1(http block)https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3REDACTED, pid is -1(http block)https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/90M5aM /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oIv6rr /usr/bin/composer install --no-interaction --prefer-dist com-symfony-httpbash(http block)https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6ab598e1bc106e6827fd346ae4a12b4a5d634c32REDACTED, pid is -1(http block)https://api.github.com/repos/phpstan/phpstan-symfony/zipball/678136545a552a33b07f1a59a013f76df286cc34REDACTED, pid is -1(http block)https://api.github.com/repos/phpstan/phpstan/zipball/9b2c7aeb83a75d8680ea5e7c9b7fca88052b766b/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/90M5aM /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oIv6rr /usr/bin/composer install --no-interaction --prefer-dist com-symfony-httpbash(http block)https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5bREDACTED, pid is -1(http block)https://api.github.com/repos/reactphp/child-process/zipball/970f0e71945556422ee4570ccbabaedc3cf04ad3REDACTED, pid is -1(http block)https://api.github.com/repos/reactphp/dns/zipball/7562c05391f42701c1fccf189c8225fece1cd7c3REDACTED, pid is -1(http block)https://api.github.com/repos/reactphp/event-loop/zipball/ba276bda6083df7e0050fd9b33f66ad7a4ac747aREDACTED, pid is -1(http block)https://api.github.com/repos/reactphp/promise/zipball/23444f53a813a3296c1368bb104793ce8d88f04aREDACTED, pid is -1(http block)https://api.github.com/repos/reactphp/socket/zipball/ef5b17b81f6f60504c539313f94f2d826c5faa08REDACTED, pid is -1(http block)https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18dREDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1dREDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/comparator/zipball/55dfef806eb7dfeb6e7a6935601fef866f8ca48dREDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2eREDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/exporter/zipball/0735b90f4da94969541dac1da743446e276defa6REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7e308268858ed6baedc8704a304727d20bc07c77REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3cREDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161dREDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/phpunit/zipball/33198268dad71e926626b618f3ec3966661e4d90REDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/47e34210757a2f37a97dcd207d032e1b01e64c7aREDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bfREDACTED, pid is -1(http block)https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/cache-contracts/zipball/5d68a57d66910405e5c0b63d6f0af941e66fc868REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/cache/zipball/5b088fa41eb9568748dc255c45e4054c387ba73bREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/config/zipball/d445badf0ad2c2a492e38c0378c39997a56ef97bREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/console/zipball/0bc2199c6c1f05276b05956f1ddc63f6d7eb5fc3REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/dependency-injection/zipball/b17882e933c4c606620247b6708ab53aa3b88753REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/dotenv/zipball/924edbc9631b75302def0258ed1697948b17baf6REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/error-handler/zipball/8c18400784fcb014dc73c8d5601a9576af7f8ad4REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/event-dispatcher/zipball/99d7e101826e6610606b9433248f80c1997cd20bREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/filesystem/zipball/441c6b69f7222aadae7cbf5df588496d5ee37789/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/90M5aM /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oIv6rr /usr/bin/composer install --no-interaction --prefer-dist com-symfony-httpbash(http block)https://api.github.com/repos/symfony/finder/zipball/24965ca011dac87431729640feef8bcf7b5523e0/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/90M5aM /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oIv6rr /usr/bin/composer install --no-interaction --prefer-dist com-symfony-httpbash(http block)https://api.github.com/repos/symfony/framework-bundle/zipball/9ef2d0b63b9e855ba351e770a603d89699115801REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/http-client-contracts/zipball/75d7043853a42837e68111812f4d964b01e5101cREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/http-client/zipball/50e5386dbef6361b6c2d9a2eb22954f8525b8921REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/http-foundation/zipball/f1a490cc9d595ba7ebe684220e625d1e472ad278REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/http-kernel/zipball/73fa5c999d7f741ca544a97d3c791cc97890ae4dREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/options-resolver/zipball/eeaa8cabe54c7b3516938c72a4a161c0cc80a34fREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/90M5aM /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oIv6rr /usr/bin/composer install --no-interaction --prefer-dist com-symfony-httpbash(http block)https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/90M5aM /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oIv6rr /usr/bin/composer install --no-interaction --prefer-dist com-symfony-httpbash(http block)https://api.github.com/repos/symfony/polyfill-php83/zipball/17f6f9a6b1735c0f163024d959f700cfbc5155e5REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/polyfill-php84/zipball/d8ced4d875142b6a7426000426b8abc631d6b191/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/90M5aM /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oIv6rr /usr/bin/composer install --no-interaction --prefer-dist com-symfony-httpbash(http block)https://api.github.com/repos/symfony/process/zipball/c46e854e79b52d07666e43924a20cb6dc546644e/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/90M5aM /usr/bin/composer install --no-interaction(http block)/usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/oIv6rr /usr/bin/composer install --no-interaction --prefer-dist com-symfony-httpbash(http block)https://api.github.com/repos/symfony/routing/zipball/0dc6253e864e71b486e8ba4970a56ab849106ebeREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/stopwatch/zipball/b67e94e06a05d9572c2fa354483b3e13e3cb1898REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/string/zipball/50590a057841fa6bf69d12eceffce3465b9e32cbREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/translation-contracts/zipball/65a8bc82080447fae78373aa10f8d13b38338977REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/translation/zipball/d6cc8e2fdd484f2f41d25938b0e8e3915de3cfbcREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/twig-bridge/zipball/1dcf980dd4f79885b986befdeb1c1bc0d6aedfc8REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/twig-bundle/zipball/a5c8dcc11a5bf9c96320da20070d2e158a4e0b30REDACTED, pid is -1(http block)https://api.github.com/repos/symfony/var-dumper/zipball/131fc9915e0343052af5ed5040401b481ca192aaREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/var-exporter/zipball/466fcac5fa2e871f83d31173f80e9c2684743bfcREDACTED, pid is -1(http block)https://api.github.com/repos/symfony/yaml/zipball/8207ae83da19ee3748d6d4f567b4d9a7c656e331REDACTED, pid is -1(http block)https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678REDACTED, pid is -1(http block)https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3cREDACTED, pid is -1(http block)https://api.github.com/repos/twigphp/Twig/zipball/a64dc5d2cc7d6cafb9347f6cd802d0d06d0351c9REDACTED, pid is -1(http block)phar.phpunit.de/usr/bin/curl curl -L REDACTED -o /tmp/phpunit.phar en est.git it /home/REDACTED/.cabash(dns block)If you need me to access, download, or install something from one of these locations, you can either: