From 09645a9da4f81368bf427bc68aa3fd2bbe2db54b Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Mon, 26 Jun 2023 19:55:56 +0200 Subject: [PATCH] Fix queryBuilder and result fetching in repositories --- .../Domain/Repository/MetadataRepository.php | 20 +++++++++++-------- .../Domain/Repository/StructureRepository.php | 5 +++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Classes/Domain/Repository/MetadataRepository.php b/Classes/Domain/Repository/MetadataRepository.php index 8a95a44892..ff39539797 100644 --- a/Classes/Domain/Repository/MetadataRepository.php +++ b/Classes/Domain/Repository/MetadataRepository.php @@ -69,7 +69,8 @@ public function findBySettings($settings = []) */ public function findWithFormat($pid, $type) { - $query = $this->getQueryBuilder() + $queryBuilder = $this->getQueryBuilder(); + $query = $queryBuilder ->select( self::TABLE . '.index_name AS index_name', 'tx_dlf_metadataformat_joins.xpath AS xpath', @@ -103,7 +104,7 @@ public function findWithFormat($pid, $type) $queryBuilder->expr()->eq('tx_dlf_metadataformat_joins.pid', $pid), $queryBuilder->expr()->eq('tx_dlf_formats_joins.type', $queryBuilder->createNamedParameter($type)) ); - return $query->execute()->fetchAll(); + return $query->execute()->fetchAllAssociative(); } /** @@ -115,7 +116,8 @@ public function findWithFormat($pid, $type) */ public function findWithoutFormat($pid) { - $query = $this->getQueryBuilder() + $queryBuilder = $this->getQueryBuilder(); + $query = $queryBuilder ->select( self::TABLE . '.index_name AS index_name', self::TABLE . '.is_sortable AS is_sortable', @@ -130,7 +132,7 @@ public function findWithoutFormat($pid) $queryBuilder->expr()->neq(self::TABLE . '.default_value', $queryBuilder->createNamedParameter('')) ); - return $query->execute()->fetchAll(); + return $query->execute()->fetchAllAssociative(); } /** @@ -150,7 +152,8 @@ public function findQueryPath($pid, $iiifVersion) * check the configuration. * TODO Saving / indexing should still work - check! */ - $query = $this->getQueryBuilder() + $queryBuilder = $this->getQueryBuilder(); + $query = $queryBuilder ->select('tx_dlf_metadataformat.xpath AS querypath') ->from(self::TABLE) ->from('tx_dlf_metadataformat') @@ -169,7 +172,7 @@ public function findQueryPath($pid, $iiifVersion) ) ); - return $query->execute()->fetchAll(); + return $query->execute()->fetchAllAssociative(); } /** @@ -182,7 +185,8 @@ public function findQueryPath($pid, $iiifVersion) */ public function findForIiif($pid, $iiifVersion) { - $query = $this->getQueryBuilder() + $queryBuilder = $this->getQueryBuilder(); + $query = $queryBuilder ->select( self::TABLE . '.index_name AS index_name', self::TABLE . '.xpath AS xpath', @@ -207,7 +211,7 @@ public function findForIiif($pid, $iiifVersion) ) ); - return $query->execute()->fetchAll(); + return $query->execute()->fetchAllAssociative(); } /** diff --git a/Classes/Domain/Repository/StructureRepository.php b/Classes/Domain/Repository/StructureRepository.php index 864d515c17..c43225cca7 100644 --- a/Classes/Domain/Repository/StructureRepository.php +++ b/Classes/Domain/Repository/StructureRepository.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Domain\Repository; +use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Database\ConnectionPool; @@ -43,6 +44,6 @@ public function findThumbnail($cPid, $type) ) ->setMaxResults(1); - return $query->execute()->fetchAll(); + return $query->execute()->fetchAllAssociative(); } -} \ No newline at end of file +}