Hello everyone,, we're updating a large application from Phalcon 2 to 3. We've found that model relations behave differently. I can't find anything in the changelog and was hoping someone could help explain.
It seems that in Phalcon 2, relations are refreshed on each access. In Phalcon 3 the related object is stored and not refreshed. Is this correct?
Here is an example of sorts with a unit test, I can post more code if helpful:
// say we have a robot with 2 parts
$this->assertEquals(2, count($robot->Parts));
// add a new part without referencing the relation
$part = new Part();
$part->name = 'Arm';
$part->robotId = $robot->Id;
$part->save();
// the robot now has 3 parts
$this->assertEquals(3, count($robot->Parts));
In Phalcon 2 this works - $robot->Parts
is correctly updated when I check the 2nd time. In Phalcon 3 the behaviour is different. The first access to robot->Parts
caches the object and it is n longer refreshed.
I can't find this in the documentation on upgrading. Thanks!