Skip to content

Commit a7c283d

Browse files
authored
Merge pull request #36 from cron-eu/fix-wizard
[BUGFIX] Upgrade wizard SQL error when there is nothing to migrate
2 parents da62860 + fe7ba57 commit a7c283d

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

Classes/Updates/MigrateRealUrlExcludeField.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ public function getDescription(): string
3838
return 'Masi - Migrate RealUrl pages.tx_realurl_exclude field to Masi pages.exclude_slug_for_subpages';
3939
}
4040

41-
public function executeUpdate(): bool
41+
protected function getExistingExcludedPages(): array
4242
{
4343
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
44-
4544
$queryBuilder = $conn->createQueryBuilder();
4645
$queryBuilder->getRestrictions()->removeAll();
4746
$existingRows = $queryBuilder
@@ -55,8 +54,18 @@ public function executeUpdate(): bool
5554
)
5655
->execute()
5756
->fetchAll();
57+
58+
return array_column($existingRows, 'uid');
59+
60+
}
61+
62+
public function executeUpdate(): bool
63+
{
64+
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
65+
$queryBuilder = $conn->createQueryBuilder();
66+
$queryBuilder->getRestrictions()->removeAll();
5867

59-
$existingPages = array_column($existingRows, 'uid');
68+
$existingPages = $this->getExistingExcludedPages();
6069

6170
$conn->createQueryBuilder()
6271
->update('pages')
@@ -77,7 +86,7 @@ public function executeUpdate(): bool
7786
return true;
7887
}
7988

80-
public function updateNecessary(): bool
89+
protected function doesRealurlFieldExist(): bool
8190
{
8291
$conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages');
8392
$columns = $conn->getSchemaManager()->listTableColumns('pages');
@@ -89,6 +98,15 @@ public function updateNecessary(): bool
8998
return false;
9099
}
91100

101+
/**
102+
* Upgrade is necessary if the environment has the "tx_realurl_exclude" column and
103+
* there is at least one page having this field set to "1", else skip the wizard
104+
*/
105+
public function updateNecessary(): bool
106+
{
107+
return $this->doesRealurlFieldExist() && count($this->getExistingExcludedPages()) > 0;
108+
}
109+
92110
public function getPrerequisites(): array
93111
{
94112
return [

0 commit comments

Comments
 (0)