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

Memory Overflow at Doctrine Module with related entities #22

Open
ThomasLandauer opened this issue Sep 10, 2017 · 1 comment
Open

Memory Overflow at Doctrine Module with related entities #22

ThomasLandauer opened this issue Sep 10, 2017 · 1 comment

Comments

@ThomasLandauer
Copy link
Member

If an entity is on the 1 side of a 1:n relationship (i.e. it has oneToMany), and I handle it with the Doctrine Module, the object gets infinitely large, thereby causing a PHP memory overflow.

Details

I've set up these two entities:

AppBundle\Entity\TestGroup:
    type: entity
    table: test_group

    id:
        id:
            type: integer
            generator:
                strategy: IDENTITY
              
    fields:
        name:
            type: string
            length: 50
            nullable: true

    oneToMany:
        test_user:
            targetEntity: TestUser
            mappedBy: test_group
AppBundle\Entity\TestUser:
    type: entity
    table: test_user

    id:
        id:
            type: integer
            generator:
                strategy: IDENTITY
              
    fields:
        group_id:
            type: integer
            nullable: true
        name:
            type: string
            length: 50
            nullable: true

    manyToOne:
        test_group:
            targetEntity:
            inversedBy: test_user
            joinColumn:
                name: group_id
                referencedColumnName: id

Now I run this functional test:

public function tryMemoryLeak (FunctionalTester $I)
{
    $group = new \AppBundle\Entity\TestGroup();
    var_dump($group);
    $I->persistEntity($group);
    die;
    var_dump($group);
}

Result: The output from var_dump is normal; and the entity exists in the database. But as soon as I remove die; the bug occurs: I get endless (i.e. hundreds or thousands of lines) output in the console. The same happens if I fetch the entity from the database with $I->grabEntityFromRepository.
This explains what I initially observed: If I try to pass the object to some function, I get a memory overflow crash from PHP.

I've tried it with SQLite and PostgreSQL.

If I do the same with the TestUser entity, everything is normal. So I'm figuring it has something to do with the oneToMany setting.

And if I do it in a controller, everything is fine too - so I'm figuring there's no error in the entities.

Setup

  • Codeception version: 2.3.5
  • PHP Version: 7.1
  • Operating System: Windows 10
@Naktibalda
Copy link
Member

Hint: it is on you to fix it

@Naktibalda Naktibalda transferred this issue from Codeception/Codeception Jan 9, 2021
@TavoNiievez TavoNiievez transferred this issue from Codeception/module-doctrine2 Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants