From 2b4ce1e102cd2b497de7ed1a4643ad999a295096 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 12 May 2026 22:24:24 +0200 Subject: [PATCH 1/2] add docs about new table entity assertion --- docs/en/appendices/5-4-migration-guide.md | 4 ++++ docs/en/orm/table-objects.md | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/en/appendices/5-4-migration-guide.md b/docs/en/appendices/5-4-migration-guide.md index 6caa212b25..ab642619a7 100644 --- a/docs/en/appendices/5-4-migration-guide.md +++ b/docs/en/appendices/5-4-migration-guide.md @@ -58,6 +58,10 @@ See [Application and Plugin Events](../core-libraries/events#registering-event-l these events were silently suppressed. They are now deferred until the outermost transaction commits, and discarded on rollback. See [Table Objects](../orm/table-objects#aftersavecommit) for more details. +- Table methods `save()`, `delete()`, `patchEntity()`, `patchEntities()` and `loadInto()` + will now throw an exception if the entity being passed down does not belong to the table instance. + This will prevent accidental data corruption or deleted records. If you don't want this new behavior + you can disable it by calling `$this->disableEntityClassAssertion();` in your `initialize()` method. ### Controller diff --git a/docs/en/orm/table-objects.md b/docs/en/orm/table-objects.md index f3d8f95c90..17191cb930 100644 --- a/docs/en/orm/table-objects.md +++ b/docs/en/orm/table-objects.md @@ -95,6 +95,15 @@ As seen in the examples above Table objects have an `initialize()` method which is called at the end of the constructor. It is recommended that you use this method to do initialization logic instead of overriding the constructor. +::: tip Added in version 5.4.0 +Table methods `save()`, `delete()`, `patchEntity()`, `patchEntities()` and `loadInto()` +will throw an exception if the entity being passed down does not belong to the table instance. +This will prevent accidental data corruption or deleted records. + +If you don't want this new behavior you can disable it by calling +`$this->disableEntityClassAssertion();` in your `initialize()` method. +::: + ### Getting Instances of a Table Class Before you can query a table, you'll need to get an instance of the table. You From dd39e90922b6554d3efd9658506ea3da61c15ccd Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Wed, 13 May 2026 09:33:36 +0200 Subject: [PATCH 2/2] add docs about new table entity assertion --- docs/en/appendices/5-4-migration-guide.md | 2 +- docs/en/orm/table-objects.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/appendices/5-4-migration-guide.md b/docs/en/appendices/5-4-migration-guide.md index ab642619a7..621f849b8a 100644 --- a/docs/en/appendices/5-4-migration-guide.md +++ b/docs/en/appendices/5-4-migration-guide.md @@ -60,7 +60,7 @@ See [Application and Plugin Events](../core-libraries/events#registering-event-l See [Table Objects](../orm/table-objects#aftersavecommit) for more details. - Table methods `save()`, `delete()`, `patchEntity()`, `patchEntities()` and `loadInto()` will now throw an exception if the entity being passed down does not belong to the table instance. - This will prevent accidental data corruption or deleted records. If you don't want this new behavior + This will prevent accidental data corruption or deleted records. If you don't want this new behavior, you can disable it by calling `$this->disableEntityClassAssertion();` in your `initialize()` method. ### Controller diff --git a/docs/en/orm/table-objects.md b/docs/en/orm/table-objects.md index 17191cb930..d778e6416d 100644 --- a/docs/en/orm/table-objects.md +++ b/docs/en/orm/table-objects.md @@ -100,7 +100,7 @@ Table methods `save()`, `delete()`, `patchEntity()`, `patchEntities()` and `load will throw an exception if the entity being passed down does not belong to the table instance. This will prevent accidental data corruption or deleted records. -If you don't want this new behavior you can disable it by calling +If you don't want this new behavior, you can disable it by calling `$this->disableEntityClassAssertion();` in your `initialize()` method. :::