Skip to content

Commit 89e8e93

Browse files
committed
Throw an InvalidConfigException when entry is missing sectionId/fieldId/ownerId
#15345
1 parent 013fa50 commit 89e8e93

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- `craft\helpers\UrlHelper::actionUrl()` now returns URLs based on the primary site’s base URL (if it has one), for console requests if the `@web` alias wasn’t explicitly defined.
6+
- An exception is now thrown when attempting to save an entry that’s missing `sectionId` or `fieldId` + `ownerId` values. ([#15345](https://github.com/craftcms/cms/discussions/15345))
67
- Fixed a bug where it wasn’t possible to expand/collapse descendants of disabled table rows within element select modals. ([#15337](https://github.com/craftcms/cms/issues/15337))
78
- Fixed a bug where addresses were getting truncated within address cards. ([#15338](https://github.com/craftcms/cms/issues/15338))
89

src/elements/Entry.php

+8
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,10 @@ public function getSupportedSites(): array
910910
return $this->getField()->getSupportedSitesForElement($this);
911911
}
912912

913+
if (!isset($this->sectionId)) {
914+
throw new InvalidConfigException('Either `sectionId` or `fieldId` + `ownerId` must be set on the entry.');
915+
}
916+
913917
$section = $this->getSection();
914918
/** @var Site[] $allSites */
915919
$allSites = ArrayHelper::index(Craft::$app->getSites()->getAllSites(true), 'id');
@@ -1027,6 +1031,10 @@ public function getUriFormat(): ?string
10271031
return $this->getField()->getUriFormatForElement($this);
10281032
}
10291033

1034+
if (!isset($this->sectionId)) {
1035+
throw new InvalidConfigException('Either `sectionId` or `fieldId` + `ownerId` must be set on the entry.');
1036+
}
1037+
10301038
$sectionSiteSettings = $this->getSection()->getSiteSettings();
10311039

10321040
if (!isset($sectionSiteSettings[$this->siteId])) {

0 commit comments

Comments
 (0)