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 @@ -2,10 +2,12 @@

## Unreleased

- Added `craft\base\ElementInterface::afterAssignedId()`.
- Fixed an error that occurred when executing the `users/remove-2fa` command non-interactively, if `--method` wasn’t provided. ([#18724](https://github.com/craftcms/cms/issues/18724))
- Fixed a bug where Link fields weren’t getting updated when the “Replace relations” element deletion option was chosen. ([#18992](https://github.com/craftcms/cms/issues/18992))
- Fixed a bug where it wasn’t always possible to select new categories or entries in relation fields. ([#18976](https://github.com/craftcms/cms/issues/18976))
- Fixed a bug where Checkboxes and Multi-select fields weren’t handling `:empty:`/`:notempty:` params properly. ([#18988](https://github.com/craftcms/cms/issues/18988), [#19019](https://github.com/craftcms/cms/pull/19019))
- Fixed a bug where entries with `{id}` in their Default Title Format weren’t always getting created with the correct generated title. ([#18991](https://github.com/craftcms/cms/issues/18991))

## 5.10.4.1 - 2026-05-28

Expand Down
7 changes: 7 additions & 0 deletions src/base/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -6653,6 +6653,13 @@ public function afterSave(bool $isNew): void
}
}

/**
* @inheritdoc
*/
public function afterAssignedId(): void
{
}

private function updateRelations(bool $isNew): void
{
if (!$this->hasFieldLayout()) {
Expand Down
7 changes: 7 additions & 0 deletions src/base/ElementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,13 @@ public function beforeSave(bool $isNew): bool;
*/
public function afterSave(bool $isNew): void;

/**
* Performs actions after the element is assigned an ID.
*
* @since 5.10.5
*/
public function afterAssignedId(): void;

/**
* Performs actions after an element is fully saved and propagated to other sites.
*
Expand Down
12 changes: 12 additions & 0 deletions src/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2991,6 +2991,18 @@ public function beforeSave(bool $isNew): bool
return parent::beforeSave($isNew);
}

/**
* @inheritdoc
*/
public function afterAssignedId(): void
{
if (ElementHelper::isDraftOrRevision($this)) {
return;
}

$this->updateTitle();
}

/**
* Set the default values for attributes if certain conditions are met.
*
Expand Down
2 changes: 2 additions & 0 deletions src/services/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -4046,6 +4046,8 @@ private function _saveElementInternal(
$element->uri = str_replace($element->tempId, (string)$element->id, $element->uri);
$element->tempId = null;
}

$element->afterAssignedId();
}
}

Expand Down