diff --git a/docs/en/appendices/5-4-migration-guide.md b/docs/en/appendices/5-4-migration-guide.md index 6caa212b25..621f849b8a 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..d778e6416d 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