Skip to content

The DI extension should not clone definitions but use ChildDefinition/DefinitionDecorator #139

Closed
@stof

Description

@stof

Currently, the DI extension retrieves the Definition for some services and clones it to create a new service. While this works fine most of the time, it can break in some cases. Definition does not perform deep cloning when being cloned (deep cloning is very complex to get right, as you might end up cloning the same object twice in 2 places referencing it, and breaking the cloned object graph where they would not share the instance). It is possible for definitions to contain mutable objects in them (mostly other Definition objects in some cases), which would break things by sharing mutations in both service definitions.

To configure multiple plugins/clients based on the existing abstract configuration, you should use the ChildDefinition feature (or its old name DefinitionDecorator when the ChildDefinition class does not exist in Symfony < 3.2)

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