Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Fixed a bug where row headings within Table fields weren’t getting statically translated in the control panel. ([#13703](https://github.com/craftcms/cms/discussions/13703))
- Fixed a bug where entry type chips within Matrix settings could be missing their action items.
- Fixed a bug where custom field override settings’ Label, Handle, and Instructions fields could be missing their placeholder values.
- Fixed a bug where site name and language values set to environment variables were getting replaced with their resolved values when installing Craft. ([#18780](https://github.com/craftcms/cms/issues/18780))
- Fixed a bug where site name values set to environment variables were getting replaced with their resolved values on save. ([#18789](https://github.com/craftcms/cms/pull/18789))

## 5.9.22 - 2026-04-29

Expand Down
4 changes: 2 additions & 2 deletions src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ public function insertDefaultData(): void
$site = $sitesService->getPrimarySite();
$site->setBaseUrl($this->site->getBaseUrl(false));
$site->hasUrls = $this->site->hasUrls;
$site->language = $this->site->language;
$site->language = $this->site->getLanguage(false);
$site->setName($this->site->getName(false));
$sitesService->saveSite($site);
}
Expand Down Expand Up @@ -1322,7 +1322,7 @@ private function _generateInitialConfig(): array
'baseUrl' => $this->site->getBaseUrl(false),
'handle' => $this->site->handle,
'hasUrls' => $this->site->hasUrls,
'language' => $this->site->language,
'language' => $this->site->getLanguage(false),
'name' => $this->site->getName(false),
'primary' => true,
'siteGroup' => $siteGroupUid,
Expand Down
18 changes: 17 additions & 1 deletion src/models/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,29 @@ public function attributeLabels(): array
];
}

/**
* @inheritdoc
*/
public function beforeValidate(): bool
{
if (!parent::beforeValidate()) {
return false;
}

// Can't use the `trim` rule because it replaces env vars
// see https://github.com/craftcms/cms/pull/18789
$this->setName(trim($this->getName(false)));

return true;
}

/**
* @inheritdoc
*/
protected function defineRules(): array
{
$rules = parent::defineRules();
$rules[] = [['name', 'handle'], 'trim'];
$rules[] = [['handle'], 'trim'];
$rules[] = [['groupId', 'name', 'handle', 'language'], 'required'];
$rules[] = [['id', 'groupId'], 'number', 'integerOnly' => true];
$rules[] = [['name', 'handle', 'baseUrl'], 'string', 'max' => 255];
Expand Down
Loading