Closed johannesx75 closed 3 days ago
Hi there, Thanks for raising this. If you'd like to create a pull request to fix it, that would go a long way towards getting this resolved.
Yeah it may be as simple as removing the call to $record->write()
- I've had a quick look a some other implementations of FormField::saveInto()
and by and large they do not call $record->write()
I'll create a pull request for it. Problem is I don't understand enough about the SearchableDropdownTrait uses yet. So I can't say for sure what the consequences of that change would be or where to look for them.
PR merged. This will be automatically tagged by GitHub Actions
Module version(s) affected
5.2.11
Description
In the
SearchableDropdownTrait::saveInto
method, if the field is a has_one relationship, it triggers $record->write() see: https://github.com/silverstripe/silverstripe-framework/blob/5/src/Forms/SearchableDropdownTrait.php#L400For DataObjects with lots of has_one relations that means, that onBeforeWrite gets called over and over again.
FormField and any other instances of saveInto should not call write - that should be called by the form itself.
How to reproduce
Reproduction steps
Possible Solution
Remove $record->write(); from
SearchableDropdownTrait
.Additional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)PRs