Skip to content

[5.x]: Primary site name and language are set to the actual environment variable values on installation #18780

@thasmo

Description

@thasmo

What happened?

Description

I have two sites configured in my project config:

baseUrl: $SITE_ALPHA_URL
enabled: true
handle: alpha
hasUrls: true
language: $SITE_ALPHA_LANGUAGE
name:  $SITE_ALPHA_NAME
primary: true
siteGroup: 74f78f86-64ac-4d6c-aeef-f4b85077ed91 # SINGLE
sortOrder: 1
baseUrl: $SITE_BETA_URL
enabled: '1'
handle: beta
hasUrls: true
language: $SITE_BETA_LANGUAGE
name: $SITE_BETA_NAME
primary: false
siteGroup: 1625d54e-a5f5-427c-93ad-bf872e3e115c # MULTI
sortOrder: 2

The env vars are defined in the .env file:

SITE_ALPHA_NAME="ALPHA"
SITE_ALPHA_URL="https://craft.ddev.site"
SITE_ALPHA_LANGUAGE="en"

SITE_BETA_NAME="BETA"
SITE_BETA_URL="https://beta.craft.ddev.site"
SITE_BETA_LANGUAGE="en"

When running craft install --interactive=0 --email=username@example.com --username=username --password=password the installation succeeds, but the configuration file of the primary site is changed to:

baseUrl: $SITE_ALPHA_URL
enabled: true
handle: alpha
hasUrls: true
-language: $SITE_ALPHA_LANGUAGE
+language: en
-name: $SITE_ALPHA_NAME
+name: ALPHA
primary: true
siteGroup: 74f78f86-64ac-4d6c-aeef-f4b85077ed91 # SINGLE
sortOrder: 1

Notice that language and name were rewritten to the actual environment variable values.

I think two things are happening:

  1. When applying the project configuration, the env var values are substituted and the substituted values are written to the database.
  2. These values from the database are then applied to the project configuration files.

Steps to reproduce

  1. Set up a project with a primary site and set name and language to env vars.
  2. Delete the database and run craft install --interactive=0 --email=username@example.com --username=username --password=password.

Expected behavior

Running craft install ... does not change the primary site values in the project configuration files. (and/or the env var values from the project config are stored as is, without substitution, in the database).

Actual behavior

Running craft install ... changes the values for the primary site to the actual environment variable values. (and the env var values from the project config are substituted and stored in the database).

Craft CMS version

5.9.22

PHP version

8.4.20

Operating system and version

Windows 11, WSL 2, Docker Desktop 4.71.0

Database type and version

PostgreSQL 17

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions