Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Infinite loop in services #21632

Copy link
Copy link
Closed
Closed
Copy link
@xocasdashdash

Description

@xocasdashdash
Issue body actions
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 2.8.9

I have a repository that needs to be constructed as a service because it depends on an another service that deals with external communications. The repo is defined as a lazy service to avoid issues with db connection.

So the service is defined like this:

service1:
    class: ClassRepository
    factory: ['@doctrine.orm.default_entity_manager', getRepository]
    arguments:
       - Class 
    calls: 
       - ["setService", "@service2"]
    lazy: true
    tags:
       - name: doctrine.repository 
       

This being a doctrine repository, I had to do a new implementation of the Repository factory to look on the container if the service is in a whitelist of repositories that we have defined as services.

The issue seems to be that the code $wrappedInstance inside the generated code seems to point to itself after initializing the value, so the php code dies out when the maximum nesting level is met.

Is this kind of use case supported? I had to add some if's to break the infinite loop but it's not something i feel very comfortable with.

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.