From fabef48ca23391c32ff403417ad03c6be102fb21 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 23 Jan 2014 17:31:08 +0000 Subject: [PATCH] [DDC-2931] testcase to reproduce Jira 2931 --- .../ORM/Functional/Ticket/DDC2931Test.php | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100755 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php new file mode 100755 index 000000000..da98a8d8a --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -0,0 +1,167 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2931User'), + )); + } catch(\Exception $e) { + + } + } + + public function testIssue() + { + $first = new DDC2931User(null); + $this->_em->persist($first); + + $second = new DDC2931User($first); + $this->_em->persist($second); + + $third = new DDC2931User($second); + $this->_em->persist($third); + + + $this->_em->flush(); + $this->_em->clear(); + + // Load Entity in second order + $second = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC2931User', $second->getId()); + // crash here with "Segmentation error" caused by infinite loop. This work correctly with doctrine 2.3 + $second->getRank(); + } +} + + +/** + * @Entity + */ +class DDC2931User +{ + + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + protected $id; + + /** + * + * @OneToOne(targetEntity="DDC2931User", inversedBy="child") + * @JoinColumn(name="parent_id", referencedColumnName="id", nullable = true) + **/ + protected $parent; + + /** + * @OneToOne(targetEntity="DDC2931User", mappedBy="parent") + **/ + protected $child; + + + /** + * Constructeur. + */ + public function __construct ($parent = null) + { + $this->parent = $parent; + } + + /** + * Return Rank recursively + * My rank is 1 + rank of my parent + * @return integer + */ + public function getRank() + { + if($this->parent == null) + return 1; + return 1 + $this->parent->getRank(); + } + + /** + * @return the $id + */ + public function getId () + { + return $this->id; + } + + /** + * @return the $parent + */ + public function getParent () + { + return $this->parent; + } + + + /** + * @param integer $id + */ + public function setId ($id) + { + $this->id = $id; + } + + /** + * @param DDC2931User $parent + */ + public function setParent ($parent) + { + $this->parent = $parent; + } + + + /** + * @return the $child + */ + public function getChild () + { + return $this->child; + } + + /** + * @param DDC2931User $child + */ + public function setChild ($child) + { + $this->child = $child; + } + + /** + * Magic getter to expose protected properties. + * + * @param string $property + * @return mixed + */ + public function __get ($property) + { + return $this->$property; + } + + /** + * Magic setter to save protected properties. + * + * @param string $property + * @param mixed $value + */ + public function __set ($property, $value) + { + $this->$property = $value; + } + +}