silverstripe / silverstripe-assets

Silverstripe Assets component
BSD 3-Clause "New" or "Revised" License
9 stars 65 forks source link

AssetControlExtension should run less queries #559

Closed lekoala closed 11 months ago

lekoala commented 1 year ago

Since it's an extension applied to all dataobject, extra caution should be taken in onBeforeWrite

https://github.com/silverstripe/silverstripe-assets/blob/e57099b0f1bfa63509307fe8da290c1dfe7a4ed1/src/AssetControlExtension.php#L72-L83

This kind of code can lead to this

image

If i understand this correctly, it means we run an uncached select query, on each write, for any dataobject ? that can't be right ? right ?

PRs

lekoala commented 1 year ago

example solution provided as PR

GuySartorelli commented 11 months ago

PR merged - it will be automatically tagged when CI has finished running on the branch.