You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
InteractsWithMedia trait defines public array $mediaCollections attribute. The registerMediaCollections method filling this array with MediaCollection instances. Each instance initializes mediaConversionRegistrations and acceptsFile with closures in constructor.
So in case when working with eloquent model serialization (in my example I'm storing models in cache) and model is "fresh" (registerMediaCollections method was not called) model can be serialized and all works properly.
But if I want to serialize model after registerMediaCollections method was called I'm getting error "Serialization of Closure is not allowed" because of closures in MediaCollection instances.
I think this attributes should not be serialized and method __sleep() or __serialize() should be defined in MediaCollection class. Or may be I'm trying to use it wrong?
This discussion was converted from issue #2320 on March 07, 2021 19:30.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Version of package:
9.4.2
InteractsWithMedia
trait definespublic array $mediaCollections
attribute. TheregisterMediaCollections
method filling this array withMediaCollection
instances. Each instance initializesmediaConversionRegistrations
andacceptsFile
with closures in constructor.So in case when working with eloquent model serialization (in my example I'm storing models in cache) and model is "fresh" (
registerMediaCollections
method was not called) model can be serialized and all works properly.But if I want to serialize model after
registerMediaCollections
method was called I'm getting error "Serialization of Closure is not allowed" because of closures inMediaCollection
instances.I think this attributes should not be serialized and method
__sleep()
or__serialize()
should be defined inMediaCollection
class. Or may be I'm trying to use it wrong?Beta Was this translation helpful? Give feedback.
All reactions