diff --git a/src/contracts/Test/Persistence/Fixture/FixtureImporter.php b/src/contracts/Test/Persistence/Fixture/FixtureImporter.php index 973c6aa8cd..407453ea49 100644 --- a/src/contracts/Test/Persistence/Fixture/FixtureImporter.php +++ b/src/contracts/Test/Persistence/Fixture/FixtureImporter.php @@ -71,7 +71,7 @@ private function truncateTables(array $tables): void try { // Cleanup before inserting (using TRUNCATE for speed, however not possible to rollback) $this->connection->executeStatement( - $dbPlatform->getTruncateTableSql($this->connection->quoteIdentifier($table)) + $dbPlatform->getTruncateTableSql($this->connection->quoteSingleIdentifier($table)) ); } catch (DBALException) { // Fallback to DELETE if TRUNCATE failed (because of FKs for instance) @@ -130,8 +130,8 @@ private function getSequenceResetStatements(array $affectedTables): iterable self::$resetSequenceStatements[$tableName] = sprintf( $queryTemplate, $sequenceName, - sprintf('MAX(%s)', $this->connection->quoteIdentifier($columnName)), - $this->connection->quoteIdentifier($tableName) + sprintf('MAX(%s)', $this->connection->quoteSingleIdentifier($columnName)), + $this->connection->quoteSingleIdentifier($tableName) ); } diff --git a/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php index c6ac39c81e..5186af0d80 100644 --- a/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/BinaryBase/BinaryBaseStorage/Gateway/DoctrineStorage.php @@ -72,9 +72,9 @@ protected function getPropertyMapping() protected function setFetchColumns(QueryBuilder $queryBuilder, $fieldId, $versionNo) { $queryBuilder->select( - $this->connection->quoteIdentifier('filename'), - $this->connection->quoteIdentifier('mime_type'), - $this->connection->quoteIdentifier('original_filename') + $this->connection->quoteSingleIdentifier('filename'), + $this->connection->quoteSingleIdentifier('mime_type'), + $this->connection->quoteSingleIdentifier('original_filename') ); } @@ -155,7 +155,7 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field) { $updateQuery = $this->connection->createQueryBuilder(); $updateQuery->update( - $this->connection->quoteIdentifier($this->getStorageTable()) + $this->connection->quoteSingleIdentifier($this->getStorageTable()) ); $this->setUpdateColumns($updateQuery, $versionInfo, $field); @@ -163,11 +163,11 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field) ->where( $updateQuery->expr()->and( $updateQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldId' ), $updateQuery->expr()->eq( - $this->connection->quoteIdentifier('version'), + $this->connection->quoteSingleIdentifier('version'), ':versionNo' ) ) @@ -187,7 +187,7 @@ protected function storeNewFieldData(VersionInfo $versionInfo, Field $field) { $insertQuery = $this->connection->createQueryBuilder(); $insertQuery->insert( - $this->connection->quoteIdentifier($this->getStorageTable()) + $this->connection->quoteSingleIdentifier($this->getStorageTable()) ); $this->setInsertColumns($insertQuery, $versionInfo, $field); @@ -224,15 +224,15 @@ public function getFileReferenceData($fieldId, $versionNo) $this->setFetchColumns($selectQuery, $fieldId, $versionNo); $selectQuery - ->from($this->connection->quoteIdentifier($this->getStorageTable())) + ->from($this->connection->quoteSingleIdentifier($this->getStorageTable())) ->where( $selectQuery->expr()->and( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldId' ), $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('version'), + $this->connection->quoteSingleIdentifier('version'), ':versionNo' ) ) @@ -320,15 +320,15 @@ public function removeFileReferences(array $fieldIds, $versionNo) $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier($this->getStorageTable())) + ->delete($this->connection->quoteSingleIdentifier($this->getStorageTable())) ->where( $deleteQuery->expr()->and( $deleteQuery->expr()->in( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldIds' ), $deleteQuery->expr()->eq( - $this->connection->quoteIdentifier('version'), + $this->connection->quoteSingleIdentifier('version'), ':versionNo' ) ) @@ -350,15 +350,15 @@ public function removeFileReference($fieldId, $versionNo) { $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier($this->getStorageTable())) + ->delete($this->connection->quoteSingleIdentifier($this->getStorageTable())) ->where( $deleteQuery->expr()->and( $deleteQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldId' ), $deleteQuery->expr()->eq( - $this->connection->quoteIdentifier('version'), + $this->connection->quoteSingleIdentifier('version'), ':versionNo' ) ) @@ -386,18 +386,18 @@ public function getReferencedFiles(array $fieldIds, $versionNo) $selectQuery = $this->connection->createQueryBuilder(); $selectQuery ->select( - $this->connection->quoteIdentifier('filename'), - $this->connection->quoteIdentifier('mime_type') + $this->connection->quoteSingleIdentifier('filename'), + $this->connection->quoteSingleIdentifier('mime_type') ) - ->from($this->connection->quoteIdentifier($this->getStorageTable())) + ->from($this->connection->quoteSingleIdentifier($this->getStorageTable())) ->where( $selectQuery->expr()->and( $selectQuery->expr()->in( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldIds' ), $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('version'), + $this->connection->quoteSingleIdentifier('version'), ':versionNo' ) ) @@ -432,23 +432,23 @@ public function countFileReferences(array $files) $selectQuery = $this->connection->createQueryBuilder(); $selectQuery ->select( - $this->connection->quoteIdentifier('filename'), - $this->connection->quoteIdentifier('mime_type'), + $this->connection->quoteSingleIdentifier('filename'), + $this->connection->quoteSingleIdentifier('mime_type'), sprintf( 'COUNT(%s) AS count', - $this->connection->quoteIdentifier('contentobject_attribute_id') + $this->connection->quoteSingleIdentifier('contentobject_attribute_id') ) ) - ->from($this->connection->quoteIdentifier($this->getStorageTable())) + ->from($this->connection->quoteSingleIdentifier($this->getStorageTable())) ->where( $selectQuery->expr()->in( - $this->connection->quoteIdentifier('filename'), + $this->connection->quoteSingleIdentifier('filename'), ':filenames' ) ) ->groupBy( - $this->connection->quoteIdentifier('filename'), - $this->connection->quoteIdentifier('mime_type') + $this->connection->quoteSingleIdentifier('filename'), + $this->connection->quoteSingleIdentifier('mime_type') ) ->setParameter( 'filenames', diff --git a/src/lib/FieldType/BinaryFile/BinaryFileStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/BinaryFile/BinaryFileStorage/Gateway/DoctrineStorage.php index 94c30558d4..e985bf98dd 100644 --- a/src/lib/FieldType/BinaryFile/BinaryFileStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/BinaryFile/BinaryFileStorage/Gateway/DoctrineStorage.php @@ -48,7 +48,7 @@ protected function setFetchColumns(QueryBuilder $queryBuilder, $fieldId, $versio parent::setFetchColumns($queryBuilder, $fieldId, $versionNo); $queryBuilder->addSelect( - $this->connection->quoteIdentifier('download_count') + $this->connection->quoteSingleIdentifier('download_count') ); } diff --git a/src/lib/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php index 9e09656e3c..9c3be70fcf 100644 --- a/src/lib/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/Image/ImageStorage/Gateway/DoctrineStorage.php @@ -45,21 +45,21 @@ public function getNodePathString(VersionInfo $versionInfo): string { $selectQuery = $this->connection->createQueryBuilder(); $selectQuery - ->select($this->connection->quoteIdentifier('path_identification_string')) - ->from($this->connection->quoteIdentifier(LocationGateway::CONTENT_TREE_TABLE)) + ->select($this->connection->quoteSingleIdentifier('path_identification_string')) + ->from($this->connection->quoteSingleIdentifier(LocationGateway::CONTENT_TREE_TABLE)) ->where( $selectQuery->expr()->and( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_id'), + $this->connection->quoteSingleIdentifier('contentobject_id'), ':contentObjectId' ), $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_version'), + $this->connection->quoteSingleIdentifier('contentobject_version'), ':versionNo' ), $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('node_id'), - $this->connection->quoteIdentifier('main_node_id') + $this->connection->quoteSingleIdentifier('node_id'), + $this->connection->quoteSingleIdentifier('main_node_id') ) ) ) @@ -80,11 +80,11 @@ public function storeImageReference(string $uri, mixed $fieldId): void $insertQuery = $this->connection->createQueryBuilder(); $insertQuery - ->insert($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE)) + ->insert($this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE)) ->values( [ - $this->connection->quoteIdentifier('contentobject_attribute_id') => ':fieldId', - $this->connection->quoteIdentifier('filepath') => ':path', + $this->connection->quoteSingleIdentifier('contentobject_attribute_id') => ':fieldId', + $this->connection->quoteSingleIdentifier('filepath') => ':path', ] ) ->setParameter('fieldId', $fieldId, ParameterType::INTEGER) @@ -102,18 +102,18 @@ public function getXmlForImages(int $versionNo, array $fieldIds): array $selectQuery = $this->connection->createQueryBuilder(); $selectQuery ->select( - $this->connection->quoteIdentifier('attr.id'), - $this->connection->quoteIdentifier('attr.data_text') + 'attr.' . $this->connection->quoteSingleIdentifier('id'), + 'attr.' . $this->connection->quoteSingleIdentifier('data_text') ) - ->from($this->connection->quoteIdentifier(ContentGateway::CONTENT_FIELD_TABLE), 'attr') + ->from($this->connection->quoteSingleIdentifier(ContentGateway::CONTENT_FIELD_TABLE), 'attr') ->where( $selectQuery->expr()->and( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('attr.version'), + 'attr.' . $this->connection->quoteSingleIdentifier('version'), ':versionNo' ), $selectQuery->expr()->in( - $this->connection->quoteIdentifier('attr.id'), + 'attr.' . $this->connection->quoteSingleIdentifier('id'), ':fieldIds' ) ) @@ -141,10 +141,10 @@ public function getAllVersionsImageXmlForFieldId(int $fieldId): array 'field.version', 'field.data_text' ) - ->from($this->connection->quoteIdentifier(ContentGateway::CONTENT_FIELD_TABLE), 'field') + ->from($this->connection->quoteSingleIdentifier(ContentGateway::CONTENT_FIELD_TABLE), 'field') ->where( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('id'), + $this->connection->quoteSingleIdentifier('id'), ':field_id' ) ) @@ -179,15 +179,15 @@ public function removeImageReferences(string $uri, int $versionNo, mixed $fieldI $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE)) + ->delete($this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE)) ->where( $deleteQuery->expr()->and( $deleteQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldId' ), $deleteQuery->expr()->like( - $this->connection->quoteIdentifier('filepath'), + $this->connection->quoteSingleIdentifier('filepath'), ':likePath' ) ) @@ -208,11 +208,11 @@ public function countImageReferences(string $uri): int $selectQuery = $this->connection->createQueryBuilder(); $selectQuery - ->select('COUNT(' . $this->connection->quoteIdentifier('id') . ')') - ->from($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE)) + ->select('COUNT(' . $this->connection->quoteSingleIdentifier('id') . ')') + ->from($this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE)) ->where( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('filepath'), + $this->connection->quoteSingleIdentifier('filepath'), ':filepath' ) ) @@ -231,10 +231,10 @@ public function isImageReferenced(string $uri): bool $selectQuery = $this->connection->createQueryBuilder(); $selectQuery ->select('1') - ->from($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE)) + ->from($this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE)) ->where( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('filepath'), + $this->connection->quoteSingleIdentifier('filepath'), ':likePath' ) ) @@ -251,7 +251,7 @@ public function countDistinctImagesData(): int $selectQuery = $this->connection->createQueryBuilder(); $selectQuery ->select('COUNT(id)') - ->from($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE)) + ->from($this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE)) ; $statement = $selectQuery->executeQuery(); @@ -265,25 +265,25 @@ protected function canRemoveImageReference(string $path, int $versionNo, int $fi $expressionBuilder = $selectQuery->expr(); $selectQuery ->select('attr.data_text') - ->from($this->connection->quoteIdentifier(ContentGateway::CONTENT_FIELD_TABLE), 'attr') + ->from($this->connection->quoteSingleIdentifier(ContentGateway::CONTENT_FIELD_TABLE), 'attr') ->innerJoin( 'attr', - $this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE), + $this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE), 'img', $expressionBuilder->eq( - $this->connection->quoteIdentifier('img.contentobject_attribute_id'), - $this->connection->quoteIdentifier('attr.id') + 'img.' . $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), + 'attr.' . $this->connection->quoteSingleIdentifier('id') ) ) ->where( $expressionBuilder->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldId' ) ) ->andWhere( $expressionBuilder->neq( - $this->connection->quoteIdentifier('version'), + $this->connection->quoteSingleIdentifier('version'), ':versionNo' ) ) @@ -351,7 +351,7 @@ public function getImagesData(int $offset, int $limit): array 'img.filepath' ) ->distinct() - ->from($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE), 'img') + ->from($this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE), 'img') ->setFirstResult($offset) ->setMaxResults($limit); @@ -364,21 +364,21 @@ public function updateImageData(int $fieldId, int $versionNo, string $xml): void $expressionBuilder = $updateQuery->expr(); $updateQuery ->update( - $this->connection->quoteIdentifier(ContentGateway::CONTENT_FIELD_TABLE) + $this->connection->quoteSingleIdentifier(ContentGateway::CONTENT_FIELD_TABLE) ) ->set( - $this->connection->quoteIdentifier('data_text'), + $this->connection->quoteSingleIdentifier('data_text'), ':xml' ) ->where( $expressionBuilder->eq( - $this->connection->quoteIdentifier('id'), + $this->connection->quoteSingleIdentifier('id'), ':field_id' ) ) ->andWhere( $expressionBuilder->eq( - $this->connection->quoteIdentifier('version'), + $this->connection->quoteSingleIdentifier('version'), ':version_no' ) ) @@ -395,21 +395,21 @@ public function updateImagePath(int $fieldId, string $oldPath, string $newPath): $expressionBuilder = $updateQuery->expr(); $updateQuery ->update( - $this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE) + $this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE) ) ->set( - $this->connection->quoteIdentifier('filepath'), + $this->connection->quoteSingleIdentifier('filepath'), ':new_path' ) ->where( $expressionBuilder->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':field_id' ) ) ->andWhere( $expressionBuilder->eq( - $this->connection->quoteIdentifier('filepath'), + $this->connection->quoteSingleIdentifier('filepath'), ':old_path' ) ) @@ -432,16 +432,16 @@ public function hasImageReference(string $uri, int $fieldId): bool $selectQuery = $this->connection->createQueryBuilder(); $selectQuery ->select('1') - ->from($this->connection->quoteIdentifier(self::IMAGE_FILE_TABLE)) + ->from($this->connection->quoteSingleIdentifier(self::IMAGE_FILE_TABLE)) ->andWhere( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('filepath'), + $this->connection->quoteSingleIdentifier('filepath'), ':path' ) ) ->andWhere( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':field_id' ) ) diff --git a/src/lib/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php index 37ec464eaa..4c79d9266c 100644 --- a/src/lib/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php @@ -106,26 +106,26 @@ protected function getAssignedKeywords(int $fieldId, int $versionNo): array $query = $this->connection->createQueryBuilder(); $expr = $query->expr(); $query - ->select($this->connection->quoteIdentifier('keyword')) - ->from($this->connection->quoteIdentifier(self::KEYWORD_TABLE), 'kwd') + ->select($this->connection->quoteSingleIdentifier('keyword')) + ->from($this->connection->quoteSingleIdentifier(self::KEYWORD_TABLE), 'kwd') ->innerJoin( 'kwd', - $this->connection->quoteIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE), + $this->connection->quoteSingleIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE), 'attr', $expr->eq( - $this->connection->quoteIdentifier('kwd.id'), - $this->connection->quoteIdentifier('attr.keyword_id') + 'kwd.' . $this->connection->quoteSingleIdentifier('id'), + 'attr.' . $this->connection->quoteSingleIdentifier('keyword_id') ) ) ->where( $expr->eq( - $this->connection->quoteIdentifier('attr.objectattribute_id'), + 'attr.' . $this->connection->quoteSingleIdentifier('objectattribute_id'), ':field_id' ) ) ->andWhere( $expr->eq( - $this->connection->quoteIdentifier('attr.version'), + 'attr.' . $this->connection->quoteSingleIdentifier('version'), ':version_no' ) ) @@ -147,8 +147,8 @@ protected function loadContentTypeId($fieldDefinitionId): int { $query = $this->connection->createQueryBuilder(); $query - ->select($this->connection->quoteIdentifier('content_type_id')) - ->from($this->connection->quoteIdentifier(ContentTypeGateway::FIELD_DEFINITION_TABLE)) + ->select($this->connection->quoteSingleIdentifier('content_type_id')) + ->from($this->connection->quoteSingleIdentifier(ContentTypeGateway::FIELD_DEFINITION_TABLE)) ->where( $query->expr()->eq('id', ':fieldDefinitionId') ) @@ -192,18 +192,18 @@ protected function getExistingKeywords($keywordList, $contentTypeId) $query = $this->connection->createQueryBuilder(); $query ->select( - $this->connection->quoteIdentifier('id'), - $this->connection->quoteIdentifier('keyword') + $this->connection->quoteSingleIdentifier('id'), + $this->connection->quoteSingleIdentifier('keyword') ) - ->from($this->connection->quoteIdentifier(self::KEYWORD_TABLE)) + ->from($this->connection->quoteSingleIdentifier(self::KEYWORD_TABLE)) ->where( $query->expr()->and( $query->expr()->in( - $this->connection->quoteIdentifier('keyword'), + $this->connection->quoteSingleIdentifier('keyword'), ':keywordList' ), $query->expr()->eq( - $this->connection->quoteIdentifier('class_id'), + $this->connection->quoteSingleIdentifier('class_id'), ':contentTypeId' ) ) @@ -249,11 +249,11 @@ protected function insertKeywords(array $keywordsToInsert, $contentTypeId) if (!empty($keywordsToInsert)) { $insertQuery = $this->connection->createQueryBuilder(); $insertQuery - ->insert($this->connection->quoteIdentifier(self::KEYWORD_TABLE)) + ->insert($this->connection->quoteSingleIdentifier(self::KEYWORD_TABLE)) ->values( [ - $this->connection->quoteIdentifier('class_id') => ':contentTypeId', - $this->connection->quoteIdentifier('keyword') => ':keyword', + $this->connection->quoteSingleIdentifier('class_id') => ':contentTypeId', + $this->connection->quoteSingleIdentifier('keyword') => ':keyword', ] ) ->setParameter('contentTypeId', $contentTypeId, ParameterType::INTEGER); @@ -272,15 +272,15 @@ protected function deleteOldKeywordAssignments(int $fieldId, int $versionNo): vo { $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE)) + ->delete($this->connection->quoteSingleIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE)) ->where( $deleteQuery->expr()->and( $deleteQuery->expr()->eq( - $this->connection->quoteIdentifier('objectattribute_id'), + $this->connection->quoteSingleIdentifier('objectattribute_id'), ':fieldId' ), $deleteQuery->expr()->eq( - $this->connection->quoteIdentifier('version'), + $this->connection->quoteSingleIdentifier('version'), ':versionNo' ) ) @@ -306,12 +306,12 @@ protected function assignKeywords(int $fieldId, array $keywordMap, int $versionN { $insertQuery = $this->connection->createQueryBuilder(); $insertQuery - ->insert($this->connection->quoteIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE)) + ->insert($this->connection->quoteSingleIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE)) ->values( [ - $this->connection->quoteIdentifier('keyword_id') => ':keywordId', - $this->connection->quoteIdentifier('objectattribute_id') => ':fieldId', - $this->connection->quoteIdentifier('version') => ':versionNo', + $this->connection->quoteSingleIdentifier('keyword_id') => ':keywordId', + $this->connection->quoteSingleIdentifier('objectattribute_id') => ':fieldId', + $this->connection->quoteSingleIdentifier('version') => ':versionNo', ] ) ; @@ -335,15 +335,15 @@ protected function deleteOrphanedKeywords() { $query = $this->connection->createQueryBuilder(); $query - ->select($this->connection->quoteIdentifier('kwd.id')) - ->from($this->connection->quoteIdentifier(self::KEYWORD_TABLE), 'kwd') + ->select('kwd.' . $this->connection->quoteSingleIdentifier('id')) + ->from($this->connection->quoteSingleIdentifier(self::KEYWORD_TABLE), 'kwd') ->leftJoin( 'kwd', - $this->connection->quoteIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE), + $this->connection->quoteSingleIdentifier(self::KEYWORD_ATTRIBUTE_LINK_TABLE), 'attr', $query->expr()->eq( - $this->connection->quoteIdentifier('attr.keyword_id'), - $this->connection->quoteIdentifier('kwd.id') + 'attr.' . $this->connection->quoteSingleIdentifier('keyword_id'), + 'kwd.' . $this->connection->quoteSingleIdentifier('id') ) ) ->where($query->expr()->isNull('attr.id')); @@ -357,9 +357,9 @@ protected function deleteOrphanedKeywords() $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier(self::KEYWORD_TABLE)) + ->delete($this->connection->quoteSingleIdentifier(self::KEYWORD_TABLE)) ->where( - $deleteQuery->expr()->in($this->connection->quoteIdentifier('id'), ':ids') + $deleteQuery->expr()->in($this->connection->quoteSingleIdentifier('id'), ':ids') ) ->setParameter('ids', $ids, ArrayParameterType::INTEGER); diff --git a/src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php index 8439766058..c448631710 100644 --- a/src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/MapLocation/MapLocationStorage/Gateway/DoctrineStorage.php @@ -73,18 +73,18 @@ public function storeFieldData(VersionInfo $versionInfo, Field $field): bool protected function updateFieldData(VersionInfo $versionInfo, Field $field) { $updateQuery = $this->connection->createQueryBuilder(); - $updateQuery->update($this->connection->quoteIdentifier(self::MAP_LOCATION_TABLE)) - ->set($this->connection->quoteIdentifier('latitude'), ':latitude') - ->set($this->connection->quoteIdentifier('longitude'), ':longitude') - ->set($this->connection->quoteIdentifier('address'), ':address') + $updateQuery->update($this->connection->quoteSingleIdentifier(self::MAP_LOCATION_TABLE)) + ->set($this->connection->quoteSingleIdentifier('latitude'), ':latitude') + ->set($this->connection->quoteSingleIdentifier('longitude'), ':longitude') + ->set($this->connection->quoteSingleIdentifier('address'), ':address') ->where( $updateQuery->expr()->and( $updateQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldId' ), $updateQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_version'), + $this->connection->quoteSingleIdentifier('contentobject_version'), ':versionNo' ) ) @@ -109,7 +109,7 @@ protected function storeNewFieldData(VersionInfo $versionInfo, Field $field) { $insertQuery = $this->connection->createQueryBuilder(); $insertQuery - ->insert($this->connection->quoteIdentifier(self::MAP_LOCATION_TABLE)) + ->insert($this->connection->quoteSingleIdentifier(self::MAP_LOCATION_TABLE)) ->values([ 'latitude' => ':latitude', 'longitude' => ':longitude', @@ -155,19 +155,19 @@ protected function loadFieldData($fieldId, $versionNo) $selectQuery = $this->connection->createQueryBuilder(); $selectQuery ->select( - $this->connection->quoteIdentifier('latitude'), - $this->connection->quoteIdentifier('longitude'), - $this->connection->quoteIdentifier('address') + $this->connection->quoteSingleIdentifier('latitude'), + $this->connection->quoteSingleIdentifier('longitude'), + $this->connection->quoteSingleIdentifier('address') ) - ->from($this->connection->quoteIdentifier(DoctrineStorage::MAP_LOCATION_TABLE)) + ->from($this->connection->quoteSingleIdentifier(DoctrineStorage::MAP_LOCATION_TABLE)) ->where( $selectQuery->expr()->and( $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldId' ), $selectQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_version'), + $this->connection->quoteSingleIdentifier('contentobject_version'), ':versionNo' ) ) @@ -218,15 +218,15 @@ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds) $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier(self::MAP_LOCATION_TABLE)) + ->delete($this->connection->quoteSingleIdentifier(self::MAP_LOCATION_TABLE)) ->where( $deleteQuery->expr()->and( $deleteQuery->expr()->in( - $this->connection->quoteIdentifier('contentobject_attribute_id'), + $this->connection->quoteSingleIdentifier('contentobject_attribute_id'), ':fieldIds' ), $deleteQuery->expr()->eq( - $this->connection->quoteIdentifier('contentobject_version'), + $this->connection->quoteSingleIdentifier('contentobject_version'), ':versionNo' ) ) diff --git a/src/lib/FieldType/Media/MediaStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/Media/MediaStorage/Gateway/DoctrineStorage.php index 1cebdaa870..688d9beba0 100644 --- a/src/lib/FieldType/Media/MediaStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/Media/MediaStorage/Gateway/DoctrineStorage.php @@ -70,11 +70,11 @@ protected function setFetchColumns(QueryBuilder $queryBuilder, $fieldId, $versio parent::setFetchColumns($queryBuilder, $fieldId, $versionNo); $queryBuilder->addSelect( - $this->connection->quoteIdentifier('has_controller'), - $this->connection->quoteIdentifier('is_autoplay'), - $this->connection->quoteIdentifier('is_loop'), - $this->connection->quoteIdentifier('width'), - $this->connection->quoteIdentifier('height') + $this->connection->quoteSingleIdentifier('has_controller'), + $this->connection->quoteSingleIdentifier('is_autoplay'), + $this->connection->quoteSingleIdentifier('is_loop'), + $this->connection->quoteSingleIdentifier('width'), + $this->connection->quoteSingleIdentifier('height') ); } diff --git a/src/lib/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php index 210a96edaf..d4a40cee7c 100644 --- a/src/lib/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php @@ -43,8 +43,8 @@ public function getIdUrlMap(array $ids) $query = $this->connection->createQueryBuilder(); $query ->select( - $this->connection->quoteIdentifier('id'), - $this->connection->quoteIdentifier('url') + $this->connection->quoteSingleIdentifier('id'), + $this->connection->quoteSingleIdentifier('url') ) ->from(self::URL_TABLE) ->where('id IN (:ids)') @@ -76,8 +76,8 @@ public function getUrlIdMap(array $urls) $query = $this->connection->createQueryBuilder(); $query ->select( - $this->connection->quoteIdentifier('id'), - $this->connection->quoteIdentifier('url') + $this->connection->quoteSingleIdentifier('id'), + $this->connection->quoteSingleIdentifier('url') ) ->from(self::URL_TABLE) ->where( @@ -108,7 +108,7 @@ public function insertUrl($url): int $query = $this->connection->createQueryBuilder(); $query - ->insert($this->connection->quoteIdentifier(self::URL_TABLE)) + ->insert($this->connection->quoteSingleIdentifier(self::URL_TABLE)) ->values( [ 'created' => ':created', @@ -140,7 +140,7 @@ public function linkUrl($urlId, $fieldId, $versionNo) $query = $this->connection->createQueryBuilder(); $query - ->insert($this->connection->quoteIdentifier(self::URL_LINK_TABLE)) + ->insert($this->connection->quoteSingleIdentifier(self::URL_LINK_TABLE)) ->values( [ 'contentobject_attribute_id' => ':contentobject_attribute_id', @@ -168,7 +168,7 @@ public function unlinkUrl($fieldId, $versionNo, array $excludeUrlIds = []): void $selectQuery = $this->connection->createQueryBuilder(); $selectQuery ->select('link.url_id') - ->from($this->connection->quoteIdentifier(self::URL_LINK_TABLE), 'link') + ->from($this->connection->quoteSingleIdentifier(self::URL_LINK_TABLE), 'link') ->where( $selectQuery->expr()->and( $selectQuery->expr()->in( @@ -193,7 +193,7 @@ public function unlinkUrl($fieldId, $versionNo, array $excludeUrlIds = []): void $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier(self::URL_LINK_TABLE)) + ->delete($this->connection->quoteSingleIdentifier(self::URL_LINK_TABLE)) ->where( $deleteQuery->expr()->and( $deleteQuery->expr()->in( @@ -238,11 +238,11 @@ private function deleteOrphanedUrls(array $potentiallyOrphanedUrls): void { $query = $this->connection->createQueryBuilder(); $query - ->select($this->connection->quoteIdentifier('url.id')) - ->from($this->connection->quoteIdentifier(self::URL_TABLE), 'url') + ->select('url.' . $this->connection->quoteSingleIdentifier('id')) + ->from($this->connection->quoteSingleIdentifier(self::URL_TABLE), 'url') ->leftJoin( 'url', - $this->connection->quoteIdentifier(self::URL_LINK_TABLE), + $this->connection->quoteSingleIdentifier(self::URL_LINK_TABLE), 'link', 'url.id = link.url_id' ) @@ -265,7 +265,7 @@ private function deleteOrphanedUrls(array $potentiallyOrphanedUrls): void $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier(self::URL_TABLE)) + ->delete($this->connection->quoteSingleIdentifier(self::URL_TABLE)) ->where($deleteQuery->expr()->in('id', ':ids')) ->setParameter('ids', $ids, ArrayParameterType::STRING) ; diff --git a/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php b/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php index 3d4927ea05..999a222a41 100644 --- a/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php +++ b/src/lib/FieldType/User/UserStorage/Gateway/DoctrineStorage.php @@ -131,12 +131,12 @@ protected function fetchUserId(int $fieldId): int $query = $this->connection->createQueryBuilder(); $query ->select( - $this->connection->quoteIdentifier('contentobject_id') + $this->connection->quoteSingleIdentifier('contentobject_id') ) - ->from($this->connection->quoteIdentifier(ContentGateway::CONTENT_FIELD_TABLE)) + ->from($this->connection->quoteSingleIdentifier(ContentGateway::CONTENT_FIELD_TABLE)) ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('id'), + $this->connection->quoteSingleIdentifier('id'), ':fieldId' ) ) @@ -153,17 +153,17 @@ protected function fetchUserData(int $userId): array $query = $this->connection->createQueryBuilder(); $query ->select( - $this->connection->quoteIdentifier('usr.contentobject_id'), - $this->connection->quoteIdentifier('usr.login'), - $this->connection->quoteIdentifier('usr.email'), - $this->connection->quoteIdentifier('usr.password_hash'), - $this->connection->quoteIdentifier('usr.password_hash_type'), - $this->connection->quoteIdentifier('usr.password_updated_at') + 'usr.' . $this->connection->quoteSingleIdentifier('contentobject_id'), + 'usr.' . $this->connection->quoteSingleIdentifier('login'), + 'usr.' . $this->connection->quoteSingleIdentifier('email'), + 'usr.' . $this->connection->quoteSingleIdentifier('password_hash'), + 'usr.' . $this->connection->quoteSingleIdentifier('password_hash_type'), + 'usr.' . $this->connection->quoteSingleIdentifier('password_updated_at') ) - ->from($this->connection->quoteIdentifier(self::USER_TABLE), 'usr') + ->from($this->connection->quoteSingleIdentifier(self::USER_TABLE), 'usr') ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('usr.contentobject_id'), + 'usr.' . $this->connection->quoteSingleIdentifier('contentobject_id'), ':userId' ) ) @@ -182,13 +182,13 @@ protected function fetchUserSettings(int $userId): array $query = $this->connection->createQueryBuilder(); $query ->select( - $this->connection->quoteIdentifier('s.is_enabled'), - $this->connection->quoteIdentifier('s.max_login') + 's.' . $this->connection->quoteSingleIdentifier('is_enabled'), + 's.' . $this->connection->quoteSingleIdentifier('max_login') ) - ->from($this->connection->quoteIdentifier(self::USER_SETTING_TABLE), 's') + ->from($this->connection->quoteSingleIdentifier(self::USER_SETTING_TABLE), 's') ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('s.user_id'), + 's.' . $this->connection->quoteSingleIdentifier('user_id'), ':userId' ) ) @@ -235,7 +235,7 @@ protected function insertFieldData(VersionInfo $versionInfo, Field $field): void $insertQuery = $this->connection->createQueryBuilder(); $insertQuery - ->insert($this->connection->quoteIdentifier(self::USER_TABLE)) + ->insert($this->connection->quoteSingleIdentifier(self::USER_TABLE)) ->setValue('contentobject_id', ':userId') ->setValue('login', ':login') ->setValue('email', ':email') @@ -255,7 +255,7 @@ protected function insertFieldData(VersionInfo $versionInfo, Field $field): void $settingsQuery = $this->connection->createQueryBuilder(); $settingsQuery - ->insert($this->connection->quoteIdentifier(self::USER_SETTING_TABLE)) + ->insert($this->connection->quoteSingleIdentifier(self::USER_SETTING_TABLE)) ->setValue('user_id', ':userId') ->setValue('is_enabled', ':isEnabled') ->setValue('max_login', ':maxLogin') @@ -271,7 +271,7 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field): void $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder - ->update($this->connection->quoteIdentifier(self::USER_TABLE)) + ->update($this->connection->quoteSingleIdentifier(self::USER_TABLE)) ->set('login', ':login') ->set('email', ':email') ->set('password_hash', ':passwordHash') @@ -284,7 +284,7 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field): void ->setParameter('passwordUpdatedAt', $field->value->externalData['passwordUpdatedAt']) ->where( $queryBuilder->expr()->eq( - $this->connection->quoteIdentifier('contentobject_id'), + $this->connection->quoteSingleIdentifier('contentobject_id'), ':userId' ) ) @@ -296,14 +296,14 @@ protected function updateFieldData(VersionInfo $versionInfo, Field $field): void $settingsQuery = $this->connection->createQueryBuilder(); $settingsQuery - ->update($this->connection->quoteIdentifier(self::USER_SETTING_TABLE)) + ->update($this->connection->quoteSingleIdentifier(self::USER_SETTING_TABLE)) ->set('is_enabled', ':isEnabled') ->set('max_login', ':maxLogin') ->setParameter('isEnabled', $field->value->externalData['enabled'], ParameterType::INTEGER) ->setParameter('maxLogin', $field->value->externalData['maxLogin'], ParameterType::INTEGER) ->where( $queryBuilder->expr()->eq( - $this->connection->quoteIdentifier('user_id'), + $this->connection->quoteSingleIdentifier('user_id'), ':userId' ) ) @@ -322,10 +322,10 @@ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): bool $query = $this->connection->createQueryBuilder(); $query - ->delete($this->connection->quoteIdentifier(self::USER_SETTING_TABLE)) + ->delete($this->connection->quoteSingleIdentifier(self::USER_SETTING_TABLE)) ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('user_id'), + $this->connection->quoteSingleIdentifier('user_id'), ':userId' ) ) @@ -335,10 +335,10 @@ public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds): bool $query = $this->connection->createQueryBuilder(); $query - ->delete($this->connection->quoteIdentifier(self::USER_TABLE)) + ->delete($this->connection->quoteSingleIdentifier(self::USER_TABLE)) ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('contentobject_id'), + $this->connection->quoteSingleIdentifier('contentobject_id'), ':userId' ) ) @@ -363,7 +363,7 @@ protected function isLastRelationToFieldType(array $fieldIds): bool ->from(ContentGateway::CONTENT_FIELD_TABLE) ->where( $checkQuery->expr()->in( - $this->connection->quoteIdentifier('id'), + $this->connection->quoteSingleIdentifier('id'), ':fieldIds' ) ) diff --git a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php index 7dab41c200..0c72286926 100644 --- a/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php @@ -126,7 +126,7 @@ public function loadLocationDataByTrashContent(int $contentId, ?int $rootLocatio $query = $this->connection->createQueryBuilder(); $query ->select('*') - ->from($this->connection->quoteIdentifier(Gateway::TRASH_TABLE), 't') + ->from($this->connection->quoteSingleIdentifier(Gateway::TRASH_TABLE), 't') ->where('t.contentobject_id = :contentobject_id') ->setParameter('contentobject_id', $contentId, ParameterType::INTEGER); diff --git a/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php index c723d3a72e..a156f669de 100644 --- a/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php @@ -1229,7 +1229,7 @@ function (string $columnName) use ($tableName, $tableAlias): string { return sprintf( '%s.%s as %s_%s', $tableAlias, - $this->connection->quoteIdentifier($columnName), + $this->connection->quoteSingleIdentifier($columnName), preg_replace('/^ibexa_/', '', $tableName), $columnName ); diff --git a/src/lib/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php index df8413f384..1fbe76aef7 100644 --- a/src/lib/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php @@ -74,7 +74,7 @@ public function loadAllLocationEntries(int $locationId): array $query = $this->connection->createQueryBuilder(); $query ->select(...array_keys(self::URL_ALIAS_DATA_COLUMN_TYPE_MAP)) - ->from($this->connection->quoteIdentifier($this->table)) + ->from($this->connection->quoteSingleIdentifier($this->table)) ->where('action = :action') ->andWhere('is_original = :is_original') ->setParameter('action', "eznode:{$locationId}", ParameterType::STRING) @@ -103,7 +103,7 @@ public function loadLocationEntries( 'text_md5', 'action' ) - ->from($this->connection->quoteIdentifier($this->table)) + ->from($this->connection->quoteSingleIdentifier($this->table)) ->where( $expr->eq( 'action', @@ -165,7 +165,7 @@ public function listGlobalEntries( 'parent', 'text_md5' ) - ->from($this->connection->quoteIdentifier($this->table)) + ->from($this->connection->quoteSingleIdentifier($this->table)) ->where( $expr->eq( 'action_type', @@ -222,7 +222,7 @@ public function isRootEntry(int $id): bool 'text', 'parent' ) - ->from($this->connection->quoteIdentifier($this->table)) + ->from($this->connection->quoteSingleIdentifier($this->table)) ->where( $query->expr()->eq( 'id', @@ -255,7 +255,7 @@ public function cleanupAfterPublish( 'text_md5', 'lang_mask' ) - ->from($this->connection->quoteIdentifier($this->table)) + ->from($this->connection->quoteSingleIdentifier($this->table)) // 1) Autogenerated aliases that match action and language... ->where( $expr->eq( @@ -343,7 +343,7 @@ public function historizeBeforeSwap(string $action, int $languageMask): void { $query = $this->connection->createQueryBuilder(); $query - ->update($this->connection->quoteIdentifier($this->table)) + ->update($this->connection->quoteSingleIdentifier($this->table)) ->set( 'is_original', $query->createPositionalParameter(0, ParameterType::INTEGER) @@ -397,7 +397,7 @@ private function historize(int $parentId, string $textMD5, int $newId): void { $query = $this->connection->createQueryBuilder(); $query - ->update($this->connection->quoteIdentifier($this->table)) + ->update($this->connection->quoteSingleIdentifier($this->table)) ->set( 'is_original', $query->createPositionalParameter(0, ParameterType::INTEGER) @@ -437,7 +437,7 @@ private function removeTranslation(int $parentId, string $textMD5, int $language { $query = $this->connection->createQueryBuilder(); $query - ->update($this->connection->quoteIdentifier($this->table)) + ->update($this->connection->quoteSingleIdentifier($this->table)) ->set( 'lang_mask', $this->getDatabasePlatform()->getBitAndComparisonExpression( @@ -481,7 +481,7 @@ public function historizeId(int $id, int $link): void 'parent', 'text_md5' )->from( - $this->connection->quoteIdentifier($this->table) + $this->connection->quoteSingleIdentifier($this->table) )->where( $query->expr()->and( $query->expr()->eq( @@ -519,7 +519,7 @@ public function reparent(int $oldParentId, int $newParentId): void { $query = $this->connection->createQueryBuilder(); $query->update( - $this->connection->quoteIdentifier($this->table) + $this->connection->quoteSingleIdentifier($this->table) )->set( 'parent', $query->createPositionalParameter($newParentId, ParameterType::INTEGER) @@ -539,7 +539,7 @@ public function reparent(int $oldParentId, int $newParentId): void public function updateRow(int $parentId, string $textMD5, array $values): void { $query = $this->connection->createQueryBuilder(); - $query->update($this->connection->quoteIdentifier($this->table)); + $query->update($this->connection->quoteSingleIdentifier($this->table)); foreach ($values as $columnName => $value) { $query->set( $columnName, @@ -597,7 +597,7 @@ public function insertRow(array $values): int } $query = $this->connection->createQueryBuilder(); - $query->insert($this->connection->quoteIdentifier($this->table)); + $query->insert($this->connection->quoteSingleIdentifier($this->table)); foreach ($values as $columnName => $value) { $query->setValue( $columnName, @@ -635,7 +635,7 @@ public function loadRow(int $parentId, string $textMD5): array { $query = $this->connection->createQueryBuilder(); $query->select('*')->from( - $this->connection->quoteIdentifier($this->table) + $this->connection->quoteSingleIdentifier($this->table) )->where( $query->expr()->and( $query->expr()->eq( @@ -683,7 +683,7 @@ static function (string $columnName) use ($tableAlias): string { array_keys(self::URL_ALIAS_DATA_COLUMN_TYPE_MAP) ) ) - ->from($this->connection->quoteIdentifier($this->table), $tableAlias); + ->from($this->connection->quoteSingleIdentifier($this->table), $tableAlias); $query ->andWhere( @@ -718,7 +718,7 @@ public function loadAutogeneratedEntry(string $action, ?int $parentId = null): a $query->select( '*' )->from( - $this->connection->quoteIdentifier($this->table) + $this->connection->quoteSingleIdentifier($this->table) )->where( $query->expr()->and( $query->expr()->eq( @@ -764,7 +764,7 @@ public function loadPathData(int $id): array 'lang_mask', 'text' )->from( - $this->connection->quoteIdentifier($this->table) + $this->connection->quoteSingleIdentifier($this->table) )->where( $query->expr()->eq( 'id', @@ -837,7 +837,7 @@ public function loadPathDataByHierarchy(array $hierarchyData): array 'lang_mask', 'text' )->from( - $this->connection->quoteIdentifier($this->table) + $this->connection->quoteSingleIdentifier($this->table) )->where( $query->expr()->or(...$hierarchyConditions) ); @@ -866,7 +866,7 @@ public function removeCustomAlias(int $parentId, string $textMD5): bool { $query = $this->connection->createQueryBuilder(); $query->delete( - $this->connection->quoteIdentifier($this->table) + $this->connection->quoteSingleIdentifier($this->table) )->where( $query->expr()->and( $query->expr()->eq( @@ -898,7 +898,7 @@ public function remove(string $action, ?int $id = null): void $query = $this->connection->createQueryBuilder(); $expr = $query->expr(); $query - ->delete($this->connection->quoteIdentifier($this->table)) + ->delete($this->connection->quoteSingleIdentifier($this->table)) ->where( $expr->eq( 'action', @@ -934,7 +934,7 @@ public function loadAutogeneratedEntries(int $parentId, bool $includeHistory = f $expr = $query->expr(); $query ->select('*') - ->from($this->connection->quoteIdentifier($this->table)) + ->from($this->connection->quoteSingleIdentifier($this->table)) ->where( $expr->eq( 'parent', @@ -1001,7 +1001,7 @@ public function bulkRemoveTranslation(int $languageId, array $actions): void { $query = $this->connection->createQueryBuilder(); $query - ->update($this->connection->quoteIdentifier($this->table)) + ->update($this->connection->quoteSingleIdentifier($this->table)) // parameter for bitwise operation has to be placed verbatim (w/o binding) for this to work cross-DBMS ->set('lang_mask', 'lang_mask & ~ ' . $languageId) ->where('action IN (:actions)') @@ -1011,7 +1011,7 @@ public function bulkRemoveTranslation(int $languageId, array $actions): void // cleanup: delete single language rows (including alwaysAvailable) $query = $this->connection->createQueryBuilder(); $query - ->delete($this->connection->quoteIdentifier($this->table)) + ->delete($this->connection->quoteSingleIdentifier($this->table)) ->where('action IN (:actions)') ->andWhere('lang_mask IN (0, 1)') ->setParameter('actions', $actions, ArrayParameterType::STRING); @@ -1085,7 +1085,7 @@ private function loadLocationEntriesMatchingMultipleLanguages( $query = $this->connection->createQueryBuilder(); $query ->select('id', 'lang_mask', 'parent', 'text_md5') - ->from($this->connection->quoteIdentifier($this->table)) + ->from($this->connection->quoteSingleIdentifier($this->table)) ->where('action = :action') // fetch rows matching any of the given Languages ->andWhere('lang_mask & :languageMask <> 0') @@ -1112,7 +1112,7 @@ public function deleteUrlAliasesWithoutLocation(): int sprintf( 'CAST(%s as %s)', $this->getDatabasePlatform()->getSubstringExpression( - $this->connection->quoteIdentifier($this->table) . '.action', + $this->connection->quoteSingleIdentifier($this->table) . '.action', '8' ), $this->getIntegerType() @@ -1122,7 +1122,7 @@ public function deleteUrlAliasesWithoutLocation(): int $deleteQuery = $this->connection->createQueryBuilder(); $deleteQuery - ->delete($this->connection->quoteIdentifier($this->table)) + ->delete($this->connection->quoteSingleIdentifier($this->table)) ->where( $deleteQuery->expr()->eq( 'action_type', @@ -1142,7 +1142,7 @@ public function deleteUrlAliasesWithoutParent(): int $query = $this->connection->createQueryBuilder(); $query - ->delete($this->connection->quoteIdentifier($this->table)) + ->delete($this->connection->quoteSingleIdentifier($this->table)) ->where( $query->expr()->neq( 'parent', @@ -1165,7 +1165,7 @@ public function deleteUrlAliasesWithBrokenLink(): int $query = $this->connection->createQueryBuilder(); $query - ->delete($this->connection->quoteIdentifier($this->table)) + ->delete($this->connection->quoteSingleIdentifier($this->table)) ->where( $query->expr()->neq('id', 'link') ) @@ -1193,7 +1193,7 @@ public function repairBrokenUrlAliasesForLocation(int $locationId): void $updateQueryBuilder = $this->connection->createQueryBuilder(); $expr = $updateQueryBuilder->expr(); $updateQueryBuilder - ->update($this->connection->quoteIdentifier($this->table)) + ->update($this->connection->quoteSingleIdentifier($this->table)) ->set('link', ':linkId') ->set('parent', ':newParentId') ->where( @@ -1359,7 +1359,7 @@ private function getAllUrlAliasesQuery(): string ->from( // nest sub-query to avoid same-table update error '(' . $innerQueryBuilder->select('id')->from( - $this->connection->quoteIdentifier($this->table) + $this->connection->quoteSingleIdentifier($this->table) )->getSQL() . ')', 'tmp' ) @@ -1393,11 +1393,11 @@ private function getUrlAliasesForLocation(int $locationId): array 'CASE t1.parent WHEN 0 THEN 0 ELSE t2.id END AS existing_parent', 't1.text_md5' ) - ->from($this->connection->quoteIdentifier($this->table), 't1') + ->from($this->connection->quoteSingleIdentifier($this->table), 't1') // selecting t2.id above will result in null if parent is broken ->leftJoin( 't1', - $this->connection->quoteIdentifier($this->table), + $this->connection->quoteSingleIdentifier($this->table), 't2', $queryBuilder->expr()->eq('t1.parent', 't2.id') ) @@ -1419,7 +1419,7 @@ private function deleteRow(int $parentId, string $textMD5): int $queryBuilder = $this->connection->createQueryBuilder(); $expr = $queryBuilder->expr(); $queryBuilder - ->delete($this->connection->quoteIdentifier($this->table)) + ->delete($this->connection->quoteSingleIdentifier($this->table)) ->where( $expr->eq( 'parent', diff --git a/src/lib/Persistence/Legacy/Setting/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Setting/Gateway/DoctrineDatabase.php index f7a785be8e..4622b4dfca 100644 --- a/src/lib/Persistence/Legacy/Setting/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Setting/Gateway/DoctrineDatabase.php @@ -34,7 +34,7 @@ public function insertSetting(string $group, string $identifier, string $seriali ->insert(self::SETTING_TABLE) ->values( [ - $this->connection->quoteIdentifier('group') => $query->createPositionalParameter($group), + $this->connection->quoteSingleIdentifier('group') => $query->createPositionalParameter($group), 'identifier' => $query->createPositionalParameter($identifier), 'value' => $query->createPositionalParameter($serializedValue), ] @@ -53,7 +53,7 @@ public function updateSetting(string $group, string $identifier, string $seriali ->set('value', $query->createPositionalParameter($serializedValue)) ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('group'), + $this->connection->quoteSingleIdentifier('group'), $query->createPositionalParameter($group, ParameterType::STRING) ), $query->expr()->eq( @@ -70,14 +70,14 @@ public function loadSetting(string $group, string $identifier): ?array $query = $this->connection->createQueryBuilder(); $query ->select( - $this->connection->quoteIdentifier('group'), + $this->connection->quoteSingleIdentifier('group'), 'identifier', 'value' ) ->from(self::SETTING_TABLE) ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('group'), + $this->connection->quoteSingleIdentifier('group'), $query->createPositionalParameter($group, ParameterType::STRING) ), $query->expr()->eq( @@ -101,7 +101,7 @@ public function loadSettingById(int $id): ?array $query = $this->connection->createQueryBuilder(); $query ->select( - $this->connection->quoteIdentifier('group'), + $this->connection->quoteSingleIdentifier('group'), 'identifier', 'value' ) @@ -130,7 +130,7 @@ public function deleteSetting(string $group, string $identifier): void ->delete(self::SETTING_TABLE) ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('group'), + $this->connection->quoteSingleIdentifier('group'), $query->createPositionalParameter($group, ParameterType::STRING) ), $query->expr()->eq( diff --git a/src/lib/Persistence/Legacy/User/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/User/Gateway/DoctrineDatabase.php index f7e3155a26..aafa70d1aa 100644 --- a/src/lib/Persistence/Legacy/User/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/User/Gateway/DoctrineDatabase.php @@ -117,7 +117,7 @@ public function updateUserPassword(User $user): void $queryBuilder = $this->connection->createQueryBuilder(); $queryBuilder - ->update($this->connection->quoteIdentifier(self::USER_TABLE)) + ->update($this->connection->quoteSingleIdentifier(self::USER_TABLE)) ->set('password_hash', ':passwordHash') ->set('password_hash_type', ':passwordHashType') ->set('password_updated_at', ':passwordUpdatedAt') @@ -126,7 +126,7 @@ public function updateUserPassword(User $user): void ->setParameter('passwordUpdatedAt', $user->passwordUpdatedAt) ->where( $queryBuilder->expr()->eq( - $this->connection->quoteIdentifier('contentobject_id'), + $this->connection->quoteSingleIdentifier('contentobject_id'), ':userId' ) ) diff --git a/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler.php b/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler.php index c64c48c8ac..1efd16fa2f 100644 --- a/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler.php +++ b/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler.php @@ -78,7 +78,7 @@ public function applyJoin( */ protected function getSortColumnName($number) { - return $this->connection->quoteIdentifier('sort_column_' . $number); + return $this->connection->quoteSingleIdentifier('sort_column_' . $number); } /** diff --git a/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler/Field.php b/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler/Field.php index 0a1d4cfada..278d151eba 100644 --- a/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler/Field.php +++ b/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler/Field.php @@ -128,7 +128,7 @@ public function applyJoin( $fieldDefinitionId = $fieldMap[$fieldTarget->typeIdentifier][$fieldTarget->fieldIdentifier]['field_definition_id']; $table = $this->getSortTableName($number); - $tableAlias = $this->connection->quoteIdentifier($table); + $tableAlias = $this->connection->quoteSingleIdentifier($table); $query ->leftJoin( 'c', diff --git a/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler/MapLocationDistance.php b/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler/MapLocationDistance.php index 3098e91ae6..ef06f4f69f 100644 --- a/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler/MapLocationDistance.php +++ b/src/lib/Search/Legacy/Content/Common/Gateway/SortClauseHandler/MapLocationDistance.php @@ -83,8 +83,8 @@ public function applyJoin( $table = $this->getSortTableName($number); $externalTable = $this->getSortTableName($number, DoctrineStorage::MAP_LOCATION_TABLE); - $tableAlias = $this->connection->quoteIdentifier($table); - $externalTableAlias = $this->connection->quoteIdentifier($externalTable); + $tableAlias = $this->connection->quoteSingleIdentifier($table); + $externalTableAlias = $this->connection->quoteSingleIdentifier($externalTable); $query ->leftJoin( 'c', diff --git a/src/lib/Search/Legacy/Content/Gateway/CriterionHandler/PermissionSubtree.php b/src/lib/Search/Legacy/Content/Gateway/CriterionHandler/PermissionSubtree.php index 7b7074275b..b19d7fd169 100644 --- a/src/lib/Search/Legacy/Content/Gateway/CriterionHandler/PermissionSubtree.php +++ b/src/lib/Search/Legacy/Content/Gateway/CriterionHandler/PermissionSubtree.php @@ -43,7 +43,7 @@ public function handle( ); } - $locationTableAlias = $this->connection->quoteIdentifier($table); + $locationTableAlias = $this->connection->quoteSingleIdentifier($table); if ($this->markTableAsJoined($queryBuilder, $locationTableAlias)) { $queryBuilder ->leftJoin( diff --git a/tests/integration/Core/Repository/LanguageServiceMaximumSupportedLanguagesTest.php b/tests/integration/Core/Repository/LanguageServiceMaximumSupportedLanguagesTest.php index a2623cefdb..bb642115fa 100644 --- a/tests/integration/Core/Repository/LanguageServiceMaximumSupportedLanguagesTest.php +++ b/tests/integration/Core/Repository/LanguageServiceMaximumSupportedLanguagesTest.php @@ -7,7 +7,6 @@ namespace Ibexa\Tests\Integration\Core\Repository; -use Ibexa\Contracts\Core\Test\Repository\SetupFactory\Legacy as LegacySetupFactory; use Ibexa\Core\Repository\LanguageService; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DependsExternal; diff --git a/tests/lib/FieldType/Url/Gateway/DoctrineStorageTest.php b/tests/lib/FieldType/Url/Gateway/DoctrineStorageTest.php index cd16e6037e..0e3213e20a 100644 --- a/tests/lib/FieldType/Url/Gateway/DoctrineStorageTest.php +++ b/tests/lib/FieldType/Url/Gateway/DoctrineStorageTest.php @@ -71,7 +71,7 @@ public function testInsertUrl(): void ->from(DoctrineDatabase::URL_TABLE) ->where( $query->expr()->eq( - $this->connection->quoteIdentifier('id'), + $this->connection->quoteSingleIdentifier('id'), ':id' ) ) @@ -114,7 +114,7 @@ public function testLinkUrl(): void ->select('*') ->from(DoctrineDatabase::URL_LINK_TABLE) ->where( - $query->expr()->eq($this->connection->quoteIdentifier('url_id'), ':urlId') + $query->expr()->eq($this->connection->quoteSingleIdentifier('url_id'), ':urlId') ) ->setParameter('urlId', $urlId, ParameterType::INTEGER) ;