Skip to content

Commit 529bdc2

Browse files
committed
Update theme config migration
1 parent e231504 commit 529bdc2

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/Migration/ThemeConfigurationMigration.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,15 @@ public function shouldRun(): bool
3535
return false;
3636
}
3737

38-
// ToDo: Rewrite
39-
/*$columns = $schemaManager->listTableColumns('tl_theme');
38+
$columns = $schemaManager->listTableColumns('tl_theme');
4039

41-
if (!isset($columns['themeConfig'])) {
42-
return false;
43-
}*/
44-
45-
try {
46-
$test = $this->connection->fetchOne("SELECT TRUE FROM tl_theme WHERE `themeConfig` NOT LIKE '%article-spacing-small%' LIMIT 1");
47-
} catch (\Exception) {
40+
if (!isset($columns['themeconfig']))
41+
{
4842
return false;
4943
}
5044

45+
$test = $this->connection->fetchOne("SELECT TRUE FROM tl_theme WHERE `themeConfig` NOT LIKE '%\"article-spacing-small%' LIMIT 1");
46+
5147
if (false !== $test)
5248
{
5349
return true;
@@ -61,11 +57,7 @@ public function shouldRun(): bool
6157
*/
6258
public function run(): MigrationResult
6359
{
64-
$values = $this->connection->fetchAllKeyValue("
65-
SELECT id, `themeConfig`
66-
FROM tl_theme
67-
WHERE `themeConfig` NOT LIKE '%article-spacing-small%'
68-
");
60+
$values = $this->connection->fetchAllKeyValue("SELECT id, themeconfig FROM tl_theme WHERE themeconfig NOT LIKE '%\"article-spacing-small%'");
6961

7062
foreach ($values as $id => $value)
7163
{
@@ -90,9 +82,9 @@ public function run(): MigrationResult
9082

9183
private function setAndUpdateConfigVariable(string $newKey, string $oldKey, array &$config): void
9284
{
93-
if (isset($config[$oldKey]) && !isset($config[$newKey]))
85+
if (!isset($config[$newKey]))
9486
{
95-
$config[$newKey] = $config[$oldKey];
87+
$config[$newKey] = $config[$oldKey] ?? 'a:2:{s:4:"unit";s:3:"rem";s:5:"value";s:3:"2.5";}';
9688
$config[$oldKey] = '$'.$newKey;
9789
}
9890
}

0 commit comments

Comments
 (0)