diff --git a/core-bundle/src/Migration/Version410/FolderUrlMigration.php b/core-bundle/src/Migration/Version410/FolderUrlMigration.php index d6f71b397c9..304ce42fd04 100644 --- a/core-bundle/src/Migration/Version410/FolderUrlMigration.php +++ b/core-bundle/src/Migration/Version410/FolderUrlMigration.php @@ -55,7 +55,7 @@ public function shouldRun(): bool if (!$this->getConfig()->has('folderUrl')) { return false; } - + return $this->getConfig()->get('folderUrl') && !$this->hasUpdatedRootPages(); } @@ -84,13 +84,15 @@ private function getConfig(): Config private function hasRootPages(): bool { - $query = "SELECT COUNT(id) FROM tl_page WHERE ".$this->connection->quoteIdentifier('type')." = 'root'"; + $query = 'SELECT COUNT(id) FROM tl_page WHERE '.$this->connection->quoteIdentifier('type')." = 'root'"; + return (int) $this->connection->executeQuery($query)->fetchColumn() > 0; } private function hasUpdatedRootPages(): bool { - $query = "SELECT COUNT(id) FROM tl_page WHERE ".$this->connection->quoteIdentifier('type')." = 'root' AND useFolderUrl = '1'"; + $query = 'SELECT COUNT(id) FROM tl_page WHERE '.$this->connection->quoteIdentifier('type')." = 'root' AND useFolderUrl = '1'"; + return (int) $this->connection->executeQuery($query)->fetchColumn() > 0; } } diff --git a/core-bundle/tests/Migration/Version410/FolderUrlMigrationTest.php b/core-bundle/tests/Migration/Version410/FolderUrlMigrationTest.php index 4326b75a474..d4329bc6815 100644 --- a/core-bundle/tests/Migration/Version410/FolderUrlMigrationTest.php +++ b/core-bundle/tests/Migration/Version410/FolderUrlMigrationTest.php @@ -10,7 +10,7 @@ * @license LGPL-3.0-or-later */ -namespace Contao\CoreBundle\Tests\Migration\Version409; +namespace Contao\CoreBundle\Tests\Migration\Version410; use Contao\Config; use Contao\CoreBundle\Migration\Version410\FolderUrlMigration;