Skip to content

Commit

Permalink
fix: import inconsistency and possible infinite loop
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Jun 2, 2020
1 parent 74b817d commit 8939329
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions inc/exportable.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ public function importChildrenObjects($item, $linker, $subItems, $input) {

public function deleteObsoleteItems(CommonDBTM $container, array $exclude)
{
if ($this instanceof CommonDBChild) {
if ($this instanceof CommonDBRelation) {
$keepCriteria = [
'itemtype' => $container->getType(),
'items_id' => $container->getID(),
];
} else {
} else if ($this instanceof CommonDBChild) {
$keepCriteria = [
$container::getForeignKeyField() => $container->getID(),
];
} else {
return true;
}
if (count($exclude) > 0) {
$keepCriteria[] = ['NOT' => ['id' => $exclude]];
Expand Down
5 changes: 3 additions & 2 deletions inc/linker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,16 @@ public function linkPostponed() {
do {
$postponedCount = 0;
$postponedAgainCount = 0;
foreach ($this->postponed as $itemtype => $postponedItemtypeList) {
foreach ($this->postponed as $itemtype => &$postponedItemtypeList) {
$postponedCount += count($postponedItemtypeList);
$newList = $postponedItemtypeList;
$newList = [];
foreach ($postponedItemtypeList as $originalId => $postponedItem) {
if ($itemtype::import($this, $postponedItem['input'], $postponedItem['relationId']) === false) {
$newList[$originalId] = $postponedItem;
$postponedAgainCount++;
}
}
$postponedItemtypeList = $newList;
}

// If no item was successfully imported, then the import is in a deadlock and fails
Expand Down

0 comments on commit 8939329

Please sign in to comment.