Closed
Description
Laravel Version
12.8.1
PHP Version
8.4
Database Driver & Version
No response
Description
Today we implemented new feature Model::automaticallyEagerLoadRelationships();
into AppServiceProvider boot method. When we try to store Model instance into redis, the exception Serialization of 'Closure' is not allowed is thrown.
If I remove automaticallyEagerLoadRelationships
from AppServiceProvider
, everything works fine.
After quick check, the problem should be in file src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
because the property $relationAutoloadCallback
can contain closure, which cannot be serialized.
Steps To Reproduce
- Add into
boot
method in AppService providerModel::automaticallyEagerLoadRelationships();
- Retrieve data from database into Model, for example:
$data = Language::query()->firstWhere('language', $language);
- Try to save it into redis via
Cache::put($cacheKey, $data, Carbon::now()->addDay());
- Exception
Serialization of 'Closure' is not allowed.
is thrown
Metadata
Metadata
Assignees
Labels
No labels