Skip to content

Commit f54d23d

Browse files
authored
Handle cases where relationship is UnsavedRelationList (#58)
* When saving a DO, error is thrown if one of the relationships is an UnsavedRalationList * Use type SS_List rather than Datalist for updateInstances() $instances param, check if DO is in database before processing in updateInatance()
1 parent 33de0e4 commit f54d23d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Services/CacheProcessingService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use SilverStripe\Core\Injector\Injectable;
77
use SilverStripe\ORM\DataList;
88
use SilverStripe\ORM\DataObject;
9+
use SilverStripe\ORM\SS_List;
910
use SilverStripe\Versioned\Versioned;
1011
use Terraformers\KeysForCache\DataTransferObjects\EdgeUpdateDto;
1112
use Terraformers\KeysForCache\Models\CacheKey;
@@ -80,7 +81,7 @@ private function updateEdge(EdgeUpdateDto $dto): array
8081
return [];
8182
}
8283

83-
private function updateInstances(DataList $instances): array
84+
private function updateInstances(SS_List $instances): array
8485
{
8586
$results = [];
8687

@@ -96,6 +97,10 @@ private function updateInstances(DataList $instances): array
9697

9798
private function updateInstance(DataObject $instance): array
9899
{
100+
if (!$instance->isInDB()) {
101+
return [];
102+
}
103+
99104
if ($this->alreadyProcessed($instance->ClassName, $instance->ID)) {
100105
return [];
101106
}

0 commit comments

Comments
 (0)