Skip to content
This repository has been archived by the owner. It is now read-only.

Fix _id sync #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Controller/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,20 +663,27 @@ protected function restoreEntries($zip, $zipHandle, $fullRestore) {
switch ($field['type']) {
case 'multiplecollectionlink':
case 'collectionlink':
foreach ($entries as $entry) {
foreach ($entries as &$entry) {
if (!isset($entry[$field['name']])) {
continue;
}
foreach ($entry[$field['name']] as $idx => $value) {
if (isset($value['_id']) && isset($idsMapping[$value['_id']])) {
$entry[$field['name']][$idx]['_id'] = $idsMapping[$value['_id']];
$this->module('collections')->save($collection['name'], [$entry]);
if (is_array($value)) {
if (isset($value['_id']) && isset($idsMapping[$value['_id']])) {
$entry[$field['name']][$idx]['_id'] = $idsMapping[$value['_id']];
}
} else {
if (isset($idsMapping[$value])) {
$entry[$field['name']]['_id'] = $idsMapping[$value];
}
}
}
}
unset($entry);
break;
}
}
$this->module('collections')->save($collection['name'], $entries);
}
}
}
Expand Down