Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Handle circular references in model serialization #52461

Merged

Commits on Aug 13, 2024

  1. [11.x] Added failing test for serializing circular relations

    If a circular relationship is set up between two models using
     `setRelation()` (or similar methods) then calling
     `$model->relationsToArray()` will call `toArray()` on each related
     model, which will in turn call `relationsToArray()`. In an instance
     where one of the related models is an object that has already had
     `toArray()` called further up the stack, it will infinitely recurse
      down and result in a stack overflow.
    
    The same issue exists with `getQueueableRelations()`, `push()`, and
     potentially other methods. This adds tests which will fail if one of
     the known potentially problematic methods gets into a recursive loop.
    samlev committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    f217dd5 View commit details
    Browse the repository at this point in the history
  2. [11.x] Added PreventsCircularRecursion

    This adds a trait for Eloquent which can be used to prevent recursively
     serializing circular references.
    samlev committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    1e175f4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    05cdf3b View commit details
    Browse the repository at this point in the history

Commits on Aug 22, 2024

  1. formatting

    taylorotwell committed Aug 22, 2024
    Configuration menu
    Copy the full SHA
    dc3dc5d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8982c36 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8df234d View commit details
    Browse the repository at this point in the history