[6.x]: Duplicate key in .env crashes the app when config is cached ("Constant … already defined")
メンテナーはふだん 1 日以内に返信
@riasvdv がすでに取り組んでいます。
2026年12月2日 から。
評価
この issue はまだ評価されていません。
説明
What happened?
Description
With a cached config (config:cache or optimize), Craft reloads .env through ConstAdapter, whose write() calls define() without checking defined(). A key that appears twice in .env then throws "Constant X already defined" and the app won't boot. Without a cached config, and in plain Laravel, duplicate keys are fine.
We hit this on a Laravel Cloud deploy, where optimize runs during the build:
Constant SESSION_DRIVER already defined, this will be an error in PHP 9
at vendor/craftcms/cms/src/Config/ConstAdapter.php:54
Steps to reproduce
- Add a duplicate key to
.env:REPRO_DUPLICATE=one REPRO_DUPLICATE=two - Run
php artisan config:cache. - Run any Artisan command, such as
php artisan about.
Expected behavior
The app boots and the last value wins, the same as without a cached config and the same as plain Laravel.
Actual behavior
Every Artisan command and request fails with Constant REPRO_DUPLICATE already defined, this will be an error in PHP 9 from ConstAdapter.php:54.
A possible fix is for ConstAdapter::write() to skip (or return false for) names that are already defined().
Craft CMS version
6.0.0-beta.3
PHP version
8.5.13
Operating system and version
macOS (Laravel Herd) locally; Laravel Cloud (production)
Database type and version
MySQL
Image driver and version
Imagick 3.8.1 (ImageMagick 7.1.2-34) on Laravel Cloud
Installed plugins and versions
- craftcms/ckeditor 6.0.0-beta.2
- 主要言語
- PHP
- スター
- 3.6k
- フォーク
- 800
- 平均マージ
- 15時間 20分
- マージ済み PR(30日)
- 715
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
craftcms/cms のほかの issue
-
bug repo:cms
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
craftcms/cms#21301 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug repo:cms
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
craftcms/cms#21307 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug repo:cms
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
craftcms/cms#21306 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug repo:cms
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
craftcms/cms#21303 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug repo:cms
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
craftcms/cms#21298 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
Document lexicon.default.userconfig and lexicon.default.userconfig.enforced in config.sample.phpオープンenhancement feature: settings good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
nextcloud/integration_openai#480 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
a11y
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
omeka/plugin-Contribution#84 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
recca0120/vscode-phpunit#620 ·
メンテナーはふだん 1 日以内に返信