Skip to content

Fix infinite recursive serialization meltdown in SimpleDTO::toArray(). #48

@hopeseekr

Description

@hopeseekr

The Problem

SimpleDTOs can contain self-references that lead to inifinite recursion. This is doubly bad with NestedDTOs, which can even contain self-references.

With the infinite recursion freeze, it gets stopped by Xdebug but in production, SimpleDTO uses up 100% of permitted RAM in php-fpm and crashes the entire server under certain situations, which is not good.

The Solution

Implement a Recursive Serialization class that detects infinite recursion. Once detected, the recursive elements should be reformatted as a string with the value of `RECURSION.

Spin this off as phpexperts/recursive-serializer. It should handle SimpleDTOs, reguarly PHP data objects, arrays, and any other class that is Traversable or Iterable.

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