Skip to content

Commit

Permalink
FIX: Stop ManyManyThroughList join records incorrectly showing as cha…
Browse files Browse the repository at this point in the history
…nged (fixes silverstripe#10821)
  • Loading branch information
kinglozzer committed Aug 21, 2023
1 parent 4f6ab33 commit e2ca3e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ORM/ManyManyThroughList.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function createDataObject($row)
if ($joinRow) {
$joinClass = $this->manipulator->getJoinClass();
$joinQueryParams = $this->manipulator->extractInheritableQueryParameters($this->dataQuery);
$joinRecord = Injector::inst()->create($joinClass, $joinRow, false, $joinQueryParams);
$joinRecord = Injector::inst()->create($joinClass, $joinRow, DataObject::CREATE_HYDRATED, $joinQueryParams);
$record->setJoin($joinRecord, $joinAlias);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/php/ORM/ManyManyThroughListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,4 +514,19 @@ public function testRemoveCallbackOnRemoveAll()
$relation->removeAll();
$this->assertEquals(sort($remove), sort($removedIds));
}

public function testChangedFields()
{
/** @var ManyManyThroughListTest\TestObject $parent */
$parent = $this->objFromFixture(ManyManyThroughListTest\TestObject::class, 'parent1');
$item1 = $parent->Items()->first();

// Nothing has changed yet
$this->assertEmpty($item1->getChangedFields());
$this->assertFalse($item1->isChanged('Title'));

// Change a field, ensure change is flagged
$item1->Title = 'a test title';
$this->assertTrue($item1->isChanged('Title'));
}
}

0 comments on commit e2ca3e9

Please sign in to comment.