Skip to content

Commit

Permalink
Merge pull request #96 from oveleon/develop
Browse files Browse the repository at this point in the history
Skip migrations for non-existing style-manager groups (#84)
  • Loading branch information
doishub authored Dec 12, 2023
2 parents a969373 + 7b86614 commit e9442be
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/StyleManager/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,28 @@
use Contao\Message;
use Contao\Model\Collection;
use Contao\StringUtil;
use Contao\System;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use DOMDocument;
use DOMElement;
use DOMNode;
use Oveleon\ContaoComponentStyleManager\Model\StyleManagerArchiveModel;
use Oveleon\ContaoComponentStyleManager\Model\StyleManagerModel;
use Psr\Log\LoggerInterface;

class Sync
{
protected ContaoFramework $framework;
protected Connection $connection;

public function __construct(ContaoFramework $framework, Connection $connection)
private ?LoggerInterface $logger;

public function __construct(ContaoFramework $framework, Connection $connection, LoggerInterface $logger = null)
{
$this->framework = $framework;
$this->connection = $connection;
$this->logger = $logger;
}

/**
Expand Down Expand Up @@ -65,6 +70,13 @@ public function shouldRunObjectConversion($table = null): bool
$key = array_keys($arrConfig)[1];
}

if (is_numeric($key) && empty(StyleManagerModel::findById($key)))
{
// Skip if the configuration was already converted or can not be found anymore as the PK does not exist
$this->logger->error('Style Manager conversion for table "'.$table.'" and id "'.$key.'" has been skipped due to primary key not existing anymore.');
return false;
}

return is_numeric($key);
}

Expand Down

0 comments on commit e9442be

Please sign in to comment.