Memory Overflow at Doctrine Module with related entities
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
調査の方向性
まず persistEntity と grabEntityFromRepository を使用する機能テストから始め、次に Doctrine モジュールが oneToMany 関係を持つエンティティをどのように処理するかを調べます。TestGroup と TestUser のケースをコントローラーの動作と比較します。関連エンティティが再帰的な出力やメモリオーバーフローを発生させなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- PHP
- スター
- 4
- フォーク
- 2
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Codeception/module-doctrine のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 38/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Codeception/module-doctrine#2 · コメント 1 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
Codeception/module-doctrine#6 · コメント 1 件 ·
Codeception/module-doctrine の issue をすべて見る
似ている issue
-
tooling
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
UX
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug customer-reported
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
MagnaCapax/PMSS#949 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Automattic/static-site-importer#1829 ·