diff --git a/installation-bundle/src/Database/Version400Update.php b/core-bundle/src/Migration/Version400/Version400Update.php similarity index 99% rename from installation-bundle/src/Database/Version400Update.php rename to core-bundle/src/Migration/Version400/Version400Update.php index 3ee128d99f5..2c1466119c8 100644 --- a/installation-bundle/src/Database/Version400Update.php +++ b/core-bundle/src/Migration/Version400/Version400Update.php @@ -10,7 +10,7 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version400; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; diff --git a/installation-bundle/src/Database/Version410Update.php b/core-bundle/src/Migration/Version401/Version410Update.php similarity index 86% rename from installation-bundle/src/Database/Version410Update.php rename to core-bundle/src/Migration/Version401/Version410Update.php index 875c4246e59..aa70d071d71 100644 --- a/installation-bundle/src/Database/Version410Update.php +++ b/core-bundle/src/Migration/Version401/Version410Update.php @@ -10,8 +10,9 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version401; +use Contao\CoreBundle\Framework\ContaoFramework; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; use Doctrine\DBAL\Connection; @@ -26,9 +27,15 @@ class Version410Update extends AbstractMigration */ private $connection; - public function __construct(Connection $connection) + /** + * @var ContaoFramework + */ + private $framework; + + public function __construct(Connection $connection, ContaoFramework $framework) { $this->connection = $connection; + $this->framework = $framework; } public function getName(): string @@ -51,6 +58,8 @@ public function shouldRun(): bool public function run(): MigrationResult { + $this->framework->initialize(); + $crop = $GLOBALS['TL_CROP']; if (empty($crop)) { diff --git a/installation-bundle/src/Database/Version430Update.php b/core-bundle/src/Migration/Version403/Version430Update.php similarity index 98% rename from installation-bundle/src/Database/Version430Update.php rename to core-bundle/src/Migration/Version403/Version430Update.php index c12a3e0fa47..81b84d9e933 100644 --- a/installation-bundle/src/Database/Version430Update.php +++ b/core-bundle/src/Migration/Version403/Version430Update.php @@ -10,7 +10,7 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version403; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; diff --git a/installation-bundle/src/Database/Version440Update.php b/core-bundle/src/Migration/Version404/Version440Update.php similarity index 98% rename from installation-bundle/src/Database/Version440Update.php rename to core-bundle/src/Migration/Version404/Version440Update.php index f7cd2cd1c56..25196354e8a 100644 --- a/installation-bundle/src/Database/Version440Update.php +++ b/core-bundle/src/Migration/Version404/Version440Update.php @@ -10,7 +10,7 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version404; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; diff --git a/installation-bundle/src/Database/Version447Update.php b/core-bundle/src/Migration/Version404/Version447Update.php similarity index 98% rename from installation-bundle/src/Database/Version447Update.php rename to core-bundle/src/Migration/Version404/Version447Update.php index 4b5307cea78..4f480fed51d 100644 --- a/installation-bundle/src/Database/Version447Update.php +++ b/core-bundle/src/Migration/Version404/Version447Update.php @@ -10,7 +10,7 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version404; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; diff --git a/installation-bundle/src/Database/Version450Update.php b/core-bundle/src/Migration/Version405/Version450Update.php similarity index 98% rename from installation-bundle/src/Database/Version450Update.php rename to core-bundle/src/Migration/Version405/Version450Update.php index d747f9e6e9c..5218d9d332a 100644 --- a/installation-bundle/src/Database/Version450Update.php +++ b/core-bundle/src/Migration/Version405/Version450Update.php @@ -10,7 +10,7 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version405; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; diff --git a/installation-bundle/src/Database/Version460Update.php b/core-bundle/src/Migration/Version406/Version460Update.php similarity index 99% rename from installation-bundle/src/Database/Version460Update.php rename to core-bundle/src/Migration/Version406/Version460Update.php index 6f801bb5d42..0a16519032e 100644 --- a/installation-bundle/src/Database/Version460Update.php +++ b/core-bundle/src/Migration/Version406/Version460Update.php @@ -10,7 +10,7 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version406; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; diff --git a/installation-bundle/src/Database/Version470Update.php b/core-bundle/src/Migration/Version407/Version470Update.php similarity index 98% rename from installation-bundle/src/Database/Version470Update.php rename to core-bundle/src/Migration/Version407/Version470Update.php index 02fe8af0f45..1117628e0d9 100644 --- a/installation-bundle/src/Database/Version470Update.php +++ b/core-bundle/src/Migration/Version407/Version470Update.php @@ -10,7 +10,7 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version407; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; diff --git a/installation-bundle/src/Database/Version480Update.php b/core-bundle/src/Migration/Version408/Version480Update.php similarity index 94% rename from installation-bundle/src/Database/Version480Update.php rename to core-bundle/src/Migration/Version408/Version480Update.php index 19ddf98b969..f5b9a189768 100644 --- a/installation-bundle/src/Database/Version480Update.php +++ b/core-bundle/src/Migration/Version408/Version480Update.php @@ -10,13 +10,14 @@ * @license LGPL-3.0-or-later */ -namespace Contao\InstallationBundle\Database; +namespace Contao\CoreBundle\Migration\Version408; use Contao\CoreBundle\Migration\AbstractMigration; use Contao\CoreBundle\Migration\MigrationResult; use Contao\File; use Contao\StringUtil; use Doctrine\DBAL\Connection; +use Symfony\Component\Filesystem\Filesystem; /** * @internal @@ -28,14 +29,20 @@ class Version480Update extends AbstractMigration */ private $connection; + /** + * @var Filesystem + */ + private $filesystem; + /** * @var string */ private $projectDir; - public function __construct(Connection $connection, string $projectDir) + public function __construct(Connection $connection, Filesystem $filesystem, string $projectDir) { $this->connection = $connection; + $this->filesystem = $filesystem; $this->projectDir = $projectDir; } @@ -153,7 +160,7 @@ public function run(): MigrationResult // Convert the important part to relative values as fractions while (false !== ($file = $statement->fetch(\PDO::FETCH_OBJ))) { - if (!file_exists($this->projectDir.'/'.$file->path) || is_dir($this->projectDir.'/'.$file->path)) { + if (!$this->filesystem->exists($this->projectDir.'/'.$file->path) || is_dir($this->projectDir.'/'.$file->path)) { continue; } diff --git a/core-bundle/src/Resources/config/migrations.yml b/core-bundle/src/Resources/config/migrations.yml index cd91ff8ef0d..dc89f3a4ca2 100644 --- a/core-bundle/src/Resources/config/migrations.yml +++ b/core-bundle/src/Resources/config/migrations.yml @@ -4,6 +4,49 @@ services: Contao\CoreBundle\Migration\MigrationCollection: ~ + Contao\CoreBundle\Migration\Version400\Version400Update: + arguments: + - '@database_connection' + + Contao\CoreBundle\Migration\Version401\Version410Update: + arguments: + - '@database_connection' + - '@contao.framework' + + Contao\CoreBundle\Migration\Version403\Version430Update: + arguments: + - '@database_connection' + + Contao\CoreBundle\Migration\Version404\Version440Update: + arguments: + - '@database_connection' + + Contao\CoreBundle\Migration\Version404\Version447Update: + arguments: + - '@database_connection' + - '@translator' + + Contao\CoreBundle\Migration\Version405\Version450Update: + arguments: + - '@database_connection' + + Contao\CoreBundle\Migration\Version406\Version460Update: + arguments: + - '@database_connection' + + Contao\CoreBundle\Migration\Version407\Version470Update: + arguments: + - '@database_connection' + - '@filesystem' + - '%contao.upload_path%' + - '%kernel.project_dir%' + + Contao\CoreBundle\Migration\Version408\Version480Update: + arguments: + - '@database_connection' + - '@filesystem' + - '%kernel.project_dir%' + Contao\CoreBundle\Migration\Version409\CeAccessMigration: arguments: - '@database_connection' diff --git a/installation-bundle/src/Database/Version330Update.php b/installation-bundle/src/Database/Version330Update.php deleted file mode 100644 index f7cb668b671..00000000000 --- a/installation-bundle/src/Database/Version330Update.php +++ /dev/null @@ -1,98 +0,0 @@ -connection = $connection; - } - - public function getName(): string - { - return 'Contao 3.3.0 Update'; - } - - public function shouldRun(): bool - { - $schemaManager = $this->connection->getSchemaManager(); - - if (!$schemaManager->tablesExist(['tl_layout'])) { - return false; - } - - $columns = $schemaManager->listTableColumns('tl_layout'); - - return !isset($columns['viewport']); - } - - public function run(): MigrationResult - { - $statement = $this->connection->query(" - SELECT - id, framework - FROM - tl_layout - WHERE - framework != '' - "); - - while (false !== ($layout = $statement->fetch(\PDO::FETCH_OBJ))) { - $framework = ''; - $tmp = StringUtil::deserialize($layout->framework); - - if (!empty($tmp) && \is_array($tmp)) { - if (false !== ($key = array_search('layout.css', $tmp, true))) { - array_insert($tmp, $key + 1, 'responsive.css'); - } - - $framework = serialize(array_values(array_unique($tmp))); - } - - $stmt = $this->connection->prepare(' - UPDATE - tl_layout - SET - framework = :framework - WHERE - id = :id - '); - - $stmt->execute([':framework' => $framework, ':id' => $layout->id]); - } - - // Add the "viewport" field (triggers the version 3.3 update) - $this->connection->query(" - ALTER TABLE - tl_layout - ADD - viewport varchar(255) NOT NULL default '' - "); - - return $this->createResult(true); - } -} diff --git a/installation-bundle/src/Database/Version350Update.php b/installation-bundle/src/Database/Version350Update.php deleted file mode 100644 index 819741c5bd0..00000000000 --- a/installation-bundle/src/Database/Version350Update.php +++ /dev/null @@ -1,81 +0,0 @@ -connection = $connection; - } - - public function getName(): string - { - return 'Contao 3.5.0 Update'; - } - - public function shouldRun(): bool - { - $schemaManager = $this->connection->getSchemaManager(); - - if (!$schemaManager->tablesExist(['tl_member'])) { - return false; - } - - $columns = $schemaManager->listTableColumns('tl_member'); - - return isset($columns['username']) && true === $columns['username']->getNotnull(); - } - - public function run(): MigrationResult - { - $this->connection->query(' - ALTER TABLE - tl_member - CHANGE - username username varchar(64) COLLATE utf8_bin NULL - '); - - $this->connection->query(" - UPDATE - tl_member - SET - username = NULL - WHERE - username = '' - "); - - $this->connection->query(' - ALTER TABLE - tl_member - DROP INDEX - username, - ADD UNIQUE KEY - username (username) - '); - - return $this->createResult(true); - } -} diff --git a/installation-bundle/src/DependencyInjection/ContaoInstallationExtension.php b/installation-bundle/src/DependencyInjection/ContaoInstallationExtension.php index 7c3dbadbfd9..ddba6bc6925 100644 --- a/installation-bundle/src/DependencyInjection/ContaoInstallationExtension.php +++ b/installation-bundle/src/DependencyInjection/ContaoInstallationExtension.php @@ -29,6 +29,5 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('commands.yml'); $loader->load('listener.yml'); $loader->load('services.yml'); - $loader->load('migrations.yml'); } } diff --git a/installation-bundle/src/Resources/config/migrations.yml b/installation-bundle/src/Resources/config/migrations.yml deleted file mode 100644 index fbda9939976..00000000000 --- a/installation-bundle/src/Resources/config/migrations.yml +++ /dev/null @@ -1,52 +0,0 @@ -services: - _defaults: - autoconfigure: true - - Contao\InstallationBundle\Database\Version330Update: - arguments: - - '@database_connection' - - Contao\InstallationBundle\Database\Version350Update: - arguments: - - '@database_connection' - - Contao\InstallationBundle\Database\Version400Update: - arguments: - - '@database_connection' - - Contao\InstallationBundle\Database\Version410Update: - arguments: - - '@database_connection' - - Contao\InstallationBundle\Database\Version430Update: - arguments: - - '@database_connection' - - Contao\InstallationBundle\Database\Version440Update: - arguments: - - '@database_connection' - - Contao\InstallationBundle\Database\Version447Update: - arguments: - - '@database_connection' - - '@translator' - - Contao\InstallationBundle\Database\Version450Update: - arguments: - - '@database_connection' - - Contao\InstallationBundle\Database\Version460Update: - arguments: - - '@database_connection' - - Contao\InstallationBundle\Database\Version470Update: - arguments: - - '@database_connection' - - '@filesystem' - - '%contao.upload_path%' - - '%kernel.project_dir%' - - Contao\InstallationBundle\Database\Version480Update: - arguments: - - '@database_connection' - - '%kernel.project_dir%' diff --git a/installation-bundle/src/Resources/config/services.yml b/installation-bundle/src/Resources/config/services.yml index 2e083fb864a..0f6b11ab038 100644 --- a/installation-bundle/src/Resources/config/services.yml +++ b/installation-bundle/src/Resources/config/services.yml @@ -2,28 +2,6 @@ services: _defaults: autoconfigure: true - Contao\InstallationBundle\Database\Version447Update: - arguments: - - '@database_connection' - - '@translator' - tags: - - { name: contao.migration, priority: 99 } - - Contao\InstallationBundle\Database\Version480Update: - arguments: - - '@database_connection' - - '%kernel.project_dir%' - tags: - - { name: contao.migration, priority: 99 } - - Contao\InstallationBundle\Database\: - resource: ../../Database/Version* - exclude: ../../Database/Version{480,447}Update.php - arguments: - - '@database_connection' - tags: - - { name: contao.migration, priority: 99 } - contao.install_tool: class: Contao\InstallationBundle\InstallTool arguments: