Skip to content

Redis cache exception with automatic relation loading enabled #55396

Closed
@boris-glumpler

Description

@boris-glumpler

Laravel Version

12.8.1

PHP Version

8.4.5

Database Driver & Version

No response

Description

When you have Model::automaticallyEagerLoadRelationships() activated and use Redis for the cache backend and try to cache a model, then you get a Serialization of 'Closure' is not allowed exception. This might happen with other cache drivers as well, but I haven't tested this. It works as expected as soon as you comment out Model::automaticallyEagerLoadRelationships().

Steps To Reproduce

  • Install https://github.com/boris-glumpler/bug-report
  • Run php artisan serve
  • Access the default route and see the exception
  • Comment out Model::automaticallyEagerLoadRelationships() in AppServiceProvider
  • Reload default route and see user data as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions