Skip to content

Commit

Permalink
fix(linker): may add several times a postponed item
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Aug 17, 2020
1 parent deb1e20 commit b37d784
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions inc/linker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function addObject($originalId, PluginFormcreatorExportableInterface $obj
$this->imported[$object->getType()] = [];
}
if (isset($this->imported[$object->getType()][$originalId])) {
throw new ImportFailureException(sprintf('Attempt to create an already created item "%1$s" with original ID "%2$s"', $object->getType(), $originalId));
throw new ImportFailureException(sprintf('Attempt to create twice the item "%1$s" with original ID "%2$s"', $object->getType(), $originalId));
}
$this->imported[$object->getType()][$originalId] = $object;
$this->progress++;
Expand Down Expand Up @@ -156,15 +156,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 b37d784

Please sign in to comment.