diff --git a/src/index/Model/ProductIndexer.php b/src/index/Model/ProductIndexer.php index 304edea..e4181db 100644 --- a/src/index/Model/ProductIndexer.php +++ b/src/index/Model/ProductIndexer.php @@ -77,15 +77,20 @@ public function executeList(array $ids): void // create temporary table to handle changelogs $this->tempTable->generateTempTableName(); $this->tempTable->create(); - foreach ($this->dimensionProvider->getIterator() as $dimension) { - try { - $this->executeByDimensions($dimension, new \ArrayIterator($ids)); - } catch (FileSystemException|RuntimeException) { - continue; + // try block here is nested to ensure that if the table was created, it gets dropped at the end + try { + foreach ($this->dimensionProvider->getIterator() as $dimension) { + try { + $this->executeByDimensions($dimension, new \ArrayIterator($ids)); + } catch (FileSystemException|RuntimeException) { + continue; + } } + $this->insertChangelogRecords->execute(); + } finally { + // we want to ensure that the "temporary" table is always dropped + $this->tempTable->drop(); } - $this->insertChangelogRecords->execute(); - $this->tempTable->drop(); } catch (\Exception $e) { $this->logger->critical($e->getMessage(), ['exception' => $e]); }