Memory Overflow at Doctrine Module with related entities
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
Direzione di ricerca
Inizia con il test funzionale usando persistEntity e grabEntityFromRepository, quindi esamina come il modulo Doctrine gestisce le entità con relazioni oneToMany. Confronta i casi TestGroup e TestUser con il comportamento del controller; il lavoro è terminato quando le entità correlate non producono più output ricorsivo né un overflow di memoria.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- PHP
- Stelle
- 4
- Fork
- 2
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Codeception/module-doctrine
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Codeception/module-doctrine#2 · 1 commento · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
Codeception/module-doctrine#6 · 1 commento ·
Tutte le issue di Codeception/module-doctrine
Issue simili
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Automattic/safe-publish#594 ·
-
needs-triage Platform(Default)
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
HttpClient
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
symfony/symfony-docs#23092 ·
-
sync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
sync-en
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100