Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

infinite loop when versionable is used with versionnable foreign table #205

Merged
merged 2 commits into from

2 participants

@themouette
Collaborator

temporary emulate the alreadyInSave process when asking sub object if need version

@willdurand willdurand merged commit 695cdae into propelorm:master
@willdurand
Owner

Can you port this patch on Propel2 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
4 generator/lib/behavior/versionable/VersionableBehaviorObjectBuilderModifier.php
@@ -192,11 +192,15 @@ public function isVersioningNecessary(\$con = null)
foreach ($this->behavior->getVersionableReferrers() as $fk) {
$fkGetter = $this->builder->getRefFKPhpNameAffix($fk, $plural = true);
$script .= "
+ // to avoid infinite loops, emulate in save
+ \$this->alreadyInSave = true;
foreach (\$this->get{$fkGetter}(null, \$con) as \$relatedObject) {
if (\$relatedObject->isVersioningNecessary(\$con)) {
+ \$this->alreadyInSave = false;
return true;
}
}
+ \$this->alreadyInSave = false;
";
}
$script .= "
View
24 ...testsuite/generator/behavior/versionable/VersionableBehaviorObjectBuilderModifierTest.php
@@ -456,6 +456,30 @@ public function testIsVersioningNecessary()
$o->save();
$this->assertFalse($o->isVersioningNecessary());
VersionableBehaviorTest1Peer::enableVersioning();
+
+ $b1 = new VersionableBehaviorTest5();
+ $b1->setFoo('Hello');
+ $b2 = new VersionableBehaviorTest5();
+ $b2->setFoo('World');
+ $a = new VersionableBehaviorTest4();
+ $a->setBar(123); // a1
+ $this->assertTrue($a->isVersioningNecessary());
+ $a->save();
+ $this->assertFalse($a->isVersioningNecessary());
+ $a->addVersionableBehaviorTest5($b1);
+ $this->assertTrue($a->isVersioningNecessary());
+ $a->save();
+ $this->assertFalse($a->isVersioningNecessary());
+ $a->addVersionableBehaviorTest5($b2);
+ $this->assertTrue($a->isVersioningNecessary());
+ $a->save();
+ $this->assertFalse($a->isVersioningNecessary());
+ $b2->setFoo('World !');
+ $this->assertTrue($b2->isVersioningNecessary());
+ $this->assertTrue($a->isVersioningNecessary());
+ $a->save();
+ $this->assertFalse($b2->isVersioningNecessary());
+ $this->assertFalse($a->isVersioningNecessary());
}
public function testAddVersionNewObject()
Something went wrong with that request. Please try again.