From 761fefd3abec6eb83ca537cf06bc9b5895279fcd Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Tue, 28 Nov 2023 12:40:02 +0100 Subject: [PATCH 1/2] [BUGFIX] Upgrade wizard SQL error when there is nothing to migrate --- .../Updates/MigrateRealUrlExcludeField.php | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Classes/Updates/MigrateRealUrlExcludeField.php b/Classes/Updates/MigrateRealUrlExcludeField.php index 9b326ed..621f7d6 100644 --- a/Classes/Updates/MigrateRealUrlExcludeField.php +++ b/Classes/Updates/MigrateRealUrlExcludeField.php @@ -38,10 +38,9 @@ public function getDescription(): string return 'Masi - Migrate RealUrl pages.tx_realurl_exclude field to Masi pages.exclude_slug_for_subpages'; } - public function executeUpdate(): bool + protected function getExistingExcludedPages() { $conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages'); - $queryBuilder = $conn->createQueryBuilder(); $queryBuilder->getRestrictions()->removeAll(); $existingRows = $queryBuilder @@ -55,8 +54,18 @@ public function executeUpdate(): bool ) ->execute() ->fetchAll(); + + return array_column($existingRows, 'uid'); + + } + + public function executeUpdate(): bool + { + $conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages'); + $queryBuilder = $conn->createQueryBuilder(); + $queryBuilder->getRestrictions()->removeAll(); - $existingPages = array_column($existingRows, 'uid'); + $existingPages = $this->getExistingExcludedPages(); $conn->createQueryBuilder() ->update('pages') @@ -77,7 +86,7 @@ public function executeUpdate(): bool return true; } - public function updateNecessary(): bool + protected function doesRealurlFieldExist(): bool { $conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages'); $columns = $conn->getSchemaManager()->listTableColumns('pages'); @@ -89,6 +98,15 @@ public function updateNecessary(): bool return false; } + /** + * Upgrade is necessary if the environment has the "tx_realurl_exclude" column and + * there is any page where has this set to "1", else skip the wizard + */ + public function updateNecessary(): bool + { + return ($this->doesRealurlFieldExist() && count($this->getExistingExcludedPages()) > 0); + } + public function getPrerequisites(): array { return [ From fe7ba570cf2cd5af9939fe882d212345f5a7c8c9 Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Wed, 29 Nov 2023 10:57:22 +0100 Subject: [PATCH 2/2] Fix review cosmetics --- Classes/Updates/MigrateRealUrlExcludeField.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Updates/MigrateRealUrlExcludeField.php b/Classes/Updates/MigrateRealUrlExcludeField.php index 621f7d6..d36e586 100644 --- a/Classes/Updates/MigrateRealUrlExcludeField.php +++ b/Classes/Updates/MigrateRealUrlExcludeField.php @@ -38,7 +38,7 @@ public function getDescription(): string return 'Masi - Migrate RealUrl pages.tx_realurl_exclude field to Masi pages.exclude_slug_for_subpages'; } - protected function getExistingExcludedPages() + protected function getExistingExcludedPages(): array { $conn = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('pages'); $queryBuilder = $conn->createQueryBuilder(); @@ -100,11 +100,11 @@ protected function doesRealurlFieldExist(): bool /** * Upgrade is necessary if the environment has the "tx_realurl_exclude" column and - * there is any page where has this set to "1", else skip the wizard + * there is at least one page having this field set to "1", else skip the wizard */ public function updateNecessary(): bool { - return ($this->doesRealurlFieldExist() && count($this->getExistingExcludedPages()) > 0); + return $this->doesRealurlFieldExist() && count($this->getExistingExcludedPages()) > 0; } public function getPrerequisites(): array