From 20b86b6990d03975ac49112280fb5f090eab8811 Mon Sep 17 00:00:00 2001 From: Sander Goossens Date: Tue, 6 Feb 2018 18:24:09 +0100 Subject: [PATCH 1/4] Revert "[AllBundles] Postgres compatibility fixes (#1778)" (#1810) [AllBundles] Revert "Postgres compatibility fixes (#1778)" --- .../Helper/Security/Acl/AclHelper.php | 36 ++++++++----------- .../Helper/Security/Acl/AclNativeHelper.php | 36 ++++++++----------- .../Helper/Security/Acl/AclHelperTest.php | 8 ++--- .../Security/Acl/AclNativeHelperTest.php | 8 ++--- .../AbstractPageAdminListConfigurator.php | 2 +- .../Helper/DoctrineDBALAdapter.php | 3 -- ...stractArticlePageAdminListConfigurator.php | 2 +- .../AbstractArticleOverviewPageRepository.php | 2 +- .../AdminList/MediaAdminListConfigurator.php | 2 +- .../MenuBundle/Form/MenuItemAdminType.php | 4 +-- .../Repository/MenuItemRepository.php | 4 +-- .../AdminList/NodeAdminListConfigurator.php | 2 +- .../NodeBundle/Form/NodeChoiceType.php | 2 +- .../NodeBundle/Repository/NodeRepository.php | 19 +++++----- .../Repository/NodeTranslationRepository.php | 18 +++++----- .../TranslationAdminListConfigurator.php | 17 ++++----- .../Repository/TranslationRepository.php | 6 ++-- 17 files changed, 74 insertions(+), 97 deletions(-) diff --git a/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php b/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php index 5af9d29f62..9def65f01e 100644 --- a/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php +++ b/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php @@ -138,12 +138,9 @@ public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissi private function getPermittedAclIdsSQLForUser(Query $query) { $aclConnection = $this->em->getConnection(); - $databasePlatform = $this->em->getConnection()->getDatabasePlatform()->getName(); + $databasePrefix = is_file($aclConnection->getDatabase()) ? '' : $aclConnection->getDatabase().'.'; $mask = $query->getHint('acl.mask'); - $rootEntity = $query->getHint('acl.root.entity'); - if ($databasePlatform === 'mysql') { - $rootEntity = str_replace('\\', '\\\\', $rootEntity); - } + $rootEntity = '"' . str_replace('\\', '\\\\', $query->getHint('acl.root.entity')) . '"'; /* @var $token TokenInterface */ $token = $this->tokenStorage->getToken(); @@ -155,42 +152,37 @@ private function getPermittedAclIdsSQLForUser(Query $query) } // Security context does not provide anonymous role automatically. - $uR = array('\'IS_AUTHENTICATED_ANONYMOUSLY\''); + $uR = array('"IS_AUTHENTICATED_ANONYMOUSLY"'); /* @var $role RoleInterface */ foreach ($userRoles as $role) { // The reason we ignore this is because by default FOSUserBundle adds ROLE_USER for every user if ($role->getRole() !== 'ROLE_USER') { - $uR[] = '\'' . $role->getRole() . '\''; + $uR[] = '"' . $role->getRole() . '"'; } } $uR = array_unique($uR); $inString = implode(' OR s.identifier = ', $uR); if (is_object($user)) { - $userClass = get_class($user); - if ($databasePlatform === 'mysql') { - $userClass = str_replace('\\', '\\\\', $userClass); - } - $inString .= ' OR s.identifier = \'' . $userClass . '-' . $user->getUserName() . '\''; - } - - $objectIdentifierColumn = 'o.object_identifier'; - if ($databasePlatform === 'postgresql') { - $objectIdentifierColumn = 'o.object_identifier::BIGINT'; + $inString .= ' OR s.identifier = "' . str_replace( + '\\', + '\\\\', + get_class($user) + ) . '-' . $user->getUserName() . '"'; } $selectQuery = <<getDatabasePlatform()->getIsNullExpression('e.object_identity_id')}) ) -LEFT JOIN acl_security_identities s ON ( +LEFT JOIN {$databasePrefix}acl_security_identities s ON ( s.id = e.security_identity_id ) -WHERE c.class_type = '{$rootEntity}' +WHERE c.class_type = {$rootEntity} AND (s.identifier = {$inString}) AND e.mask & {$mask} > 0 SELECTQUERY; diff --git a/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclNativeHelper.php b/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclNativeHelper.php index 74d2c75222..a3a0d7dc22 100644 --- a/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclNativeHelper.php +++ b/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclNativeHelper.php @@ -59,15 +59,13 @@ public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissi { $aclConnection = $this->em->getConnection(); + $databasePrefix = is_file($aclConnection->getDatabase()) ? '' : $aclConnection->getDatabase().'.'; $rootEntity = $permissionDef->getEntity(); $linkAlias = $permissionDef->getAlias(); // Only tables with a single ID PK are currently supported $linkField = $this->em->getClassMetadata($rootEntity)->getSingleIdentifierColumnName(); - $databasePlatform = $this->em->getConnection()->getDatabasePlatform()->getName(); - if ($databasePlatform === 'mysql') { - $rootEntity = str_replace('\\', '\\\\', $rootEntity); - } + $rootEntity = '"' . str_replace('\\', '\\\\', $rootEntity) . '"'; $query = $queryBuilder; $builder = new MaskBuilder(); @@ -86,43 +84,37 @@ public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissi } // Security context does not provide anonymous role automatically. - $uR = array('\'IS_AUTHENTICATED_ANONYMOUSLY\''); + $uR = array('"IS_AUTHENTICATED_ANONYMOUSLY"'); /* @var $role RoleInterface */ foreach ($userRoles as $role) { // The reason we ignore this is because by default FOSUserBundle adds ROLE_USER for every user if ($role->getRole() !== 'ROLE_USER') { - $uR[] = '\'' . $role->getRole() . '\''; + $uR[] = '"' . $role->getRole() . '"'; } } $uR = array_unique($uR); $inString = implode(' OR s.identifier = ', (array) $uR); if (is_object($user)) { - $userClass = get_class($user); - if ($databasePlatform === 'mysql') { - $userClass = str_replace('\\', '\\\\', $userClass); - } - - $inString .= ' OR s.identifier = \'' . $userClass . '-' . $user->getUserName() . '\''; - } - - $objectIdentifierColumn = 'o.object_identifier'; - if ($databasePlatform === 'postgresql') { - $objectIdentifierColumn = 'o.object_identifier::BIGINT'; + $inString .= ' OR s.identifier = "' . str_replace( + '\\', + '\\\\', + get_class($user) + ) . '-' . $user->getUserName() . '"'; } $joinTableQuery = <<getDatabasePlatform()->getIsNullExpression('e.object_identity_id')}) ) -LEFT JOIN acl_security_identities s ON ( +LEFT JOIN {$databasePrefix}acl_security_identities s ON ( s.id = e.security_identity_id ) -WHERE c.class_type = '{$rootEntity}' +WHERE c.class_type = {$rootEntity} AND (s.identifier = {$inString}) AND e.mask & {$mask} > 0 SELECTQUERY; diff --git a/src/Kunstmaan/AdminBundle/Tests/Helper/Security/Acl/AclHelperTest.php b/src/Kunstmaan/AdminBundle/Tests/Helper/Security/Acl/AclHelperTest.php index 64dd3082c7..e1fd9ab316 100644 --- a/src/Kunstmaan/AdminBundle/Tests/Helper/Security/Acl/AclHelperTest.php +++ b/src/Kunstmaan/AdminBundle/Tests/Helper/Security/Acl/AclHelperTest.php @@ -220,9 +220,9 @@ public function testApply() $this->assertEquals('n', $query->getHint('acl.entityRootTableDqlAlias')); $aclQuery = $query->getHint('acl.extra.query'); - $this->assertContains('\'ROLE_SUBJECT\'', $aclQuery); - $this->assertContains('\'ROLE_KING\'', $aclQuery); - $this->assertContains('\'IS_AUTHENTICATED_ANONYMOUSLY\'', $aclQuery); + $this->assertContains('"ROLE_SUBJECT"', $aclQuery); + $this->assertContains('"ROLE_KING"', $aclQuery); + $this->assertContains('"IS_AUTHENTICATED_ANONYMOUSLY"', $aclQuery); $this->assertContains('MyUser', $aclQuery); } @@ -277,7 +277,7 @@ public function testApplyAnonymous() $this->assertEquals('n', $query->getHint('acl.entityRootTableDqlAlias')); $aclQuery = $query->getHint('acl.extra.query'); - $this->assertContains('\'IS_AUTHENTICATED_ANONYMOUSLY\'', $aclQuery); + $this->assertContains('"IS_AUTHENTICATED_ANONYMOUSLY"', $aclQuery); } /** diff --git a/src/Kunstmaan/AdminBundle/Tests/Helper/Security/Acl/AclNativeHelperTest.php b/src/Kunstmaan/AdminBundle/Tests/Helper/Security/Acl/AclNativeHelperTest.php index f304e8ad96..0a95054643 100644 --- a/src/Kunstmaan/AdminBundle/Tests/Helper/Security/Acl/AclNativeHelperTest.php +++ b/src/Kunstmaan/AdminBundle/Tests/Helper/Security/Acl/AclNativeHelperTest.php @@ -167,9 +167,9 @@ public function testApply() $qb = $this->object->apply($queryBuilder, $permissionDef); $query = $qb->getSQL(); - $this->assertContains('\'ROLE_SUBJECT\'', $query); - $this->assertContains('\'ROLE_KING\'', $query); - $this->assertContains('\'IS_AUTHENTICATED_ANONYMOUSLY\'', $query); + $this->assertContains('"ROLE_SUBJECT"', $query); + $this->assertContains('"ROLE_KING"', $query); + $this->assertContains('"IS_AUTHENTICATED_ANONYMOUSLY"', $query); $this->assertContains('MyUser', $query); } @@ -210,7 +210,7 @@ public function testApplyAnonymous() $qb = $this->object->apply($queryBuilder, $permissionDef); $query = $qb->getSQL(); - $this->assertContains('\'IS_AUTHENTICATED_ANONYMOUSLY\'', $query); + $this->assertContains('"IS_AUTHENTICATED_ANONYMOUSLY"', $query); } /** diff --git a/src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractPageAdminListConfigurator.php b/src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractPageAdminListConfigurator.php index 2af6ee6ef7..5f8b6e0c72 100644 --- a/src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractPageAdminListConfigurator.php +++ b/src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractPageAdminListConfigurator.php @@ -112,7 +112,7 @@ public function adaptQueryBuilder(QueryBuilder $queryBuilder, array $params = [] ->from('kuma_node_translations', 'nt') ->innerJoin('nt', 'kuma_nodes', 'n', 'nt.node_id = n.id') ->where('n.ref_entity_name = :pageClass') - ->andWhere('n.deleted = false') + ->andWhere('n.deleted = 0') ->orderBy('nt.updated', 'DESC'); /** diff --git a/src/Kunstmaan/AdminListBundle/Helper/DoctrineDBALAdapter.php b/src/Kunstmaan/AdminListBundle/Helper/DoctrineDBALAdapter.php index a7aa1e6ef2..0f753a3be4 100644 --- a/src/Kunstmaan/AdminListBundle/Helper/DoctrineDBALAdapter.php +++ b/src/Kunstmaan/AdminListBundle/Helper/DoctrineDBALAdapter.php @@ -65,14 +65,11 @@ public function getNbResults() { $query = clone $this->queryBuilder; $distinctString = ''; - $groupBy = null; if ($this->useDistinct) { - $groupBy = $this->countField; $distinctString = 'DISTINCT '; } $statement = $query->select('COUNT('. $distinctString . $this->countField.') AS total_results') ->orderBy($this->countField) - ->groupBy($groupBy) ->setMaxResults(1) ->execute(); diff --git a/src/Kunstmaan/ArticleBundle/AdminList/AbstractArticlePageAdminListConfigurator.php b/src/Kunstmaan/ArticleBundle/AdminList/AbstractArticlePageAdminListConfigurator.php index 39b04dcd9f..e8df4aa88a 100644 --- a/src/Kunstmaan/ArticleBundle/AdminList/AbstractArticlePageAdminListConfigurator.php +++ b/src/Kunstmaan/ArticleBundle/AdminList/AbstractArticlePageAdminListConfigurator.php @@ -105,7 +105,7 @@ public function adaptQueryBuilder(QueryBuilder $queryBuilder) $queryBuilder->innerJoin('b.node', 'n', 'WITH', 'b.node = n.id'); $queryBuilder->innerJoin('b.nodeVersions', 'nv', 'WITH', 'b.publicNodeVersion = nv.id'); $queryBuilder->andWhere('b.lang = :lang'); - $queryBuilder->andWhere('n.deleted = false'); + $queryBuilder->andWhere('n.deleted = 0'); $queryBuilder->andWhere('n.refEntityName = :class'); $queryBuilder->addOrderBy("b.updated", "DESC"); $queryBuilder->setParameter('lang', $this->locale); diff --git a/src/Kunstmaan/ArticleBundle/Repository/AbstractArticleOverviewPageRepository.php b/src/Kunstmaan/ArticleBundle/Repository/AbstractArticleOverviewPageRepository.php index bbfc89303f..19a8a00df9 100644 --- a/src/Kunstmaan/ArticleBundle/Repository/AbstractArticleOverviewPageRepository.php +++ b/src/Kunstmaan/ArticleBundle/Repository/AbstractArticleOverviewPageRepository.php @@ -18,7 +18,7 @@ public function findActiveOverviewPages() ->innerJoin('KunstmaanNodeBundle:NodeVersion', 'v', 'WITH', 'a.id = v.refId') ->innerJoin('KunstmaanNodeBundle:NodeTranslation', 't', 'WITH', 't.publicNodeVersion = v.id') ->innerJoin('KunstmaanNodeBundle:Node', 'n', 'WITH', 't.node = n.id') - ->where('n.deleted = false') + ->where('n.deleted = 0') ->andWhere('v.refEntityName = :refname') ->setParameter('refname', $this->getEntityName()); diff --git a/src/Kunstmaan/MediaBundle/AdminList/MediaAdminListConfigurator.php b/src/Kunstmaan/MediaBundle/AdminList/MediaAdminListConfigurator.php index 19339d9257..c94688f966 100644 --- a/src/Kunstmaan/MediaBundle/AdminList/MediaAdminListConfigurator.php +++ b/src/Kunstmaan/MediaBundle/AdminList/MediaAdminListConfigurator.php @@ -178,7 +178,7 @@ public function adaptQueryBuilder(QueryBuilder $queryBuilder) { $queryBuilder->andWhere('b.folder = :folder') ->setParameter('folder', $this->folder->getId()) - ->andWhere('b.deleted = false') + ->andWhere('b.deleted = 0') ->orderBy('b.updatedAt', 'DESC'); if ($this->request->get('_route') == 'KunstmaanMediaBundle_chooser_show_folder') { diff --git a/src/Kunstmaan/MenuBundle/Form/MenuItemAdminType.php b/src/Kunstmaan/MenuBundle/Form/MenuItemAdminType.php index 2ee6ec71a9..a98b7aab00 100644 --- a/src/Kunstmaan/MenuBundle/Form/MenuItemAdminType.php +++ b/src/Kunstmaan/MenuBundle/Form/MenuItemAdminType.php @@ -91,10 +91,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) $qb = $er->createQueryBuilder('nt') ->innerJoin('nt.publicNodeVersion', 'nv') ->innerJoin('nt.node', 'n') - ->where('n.deleted = false') + ->where('n.deleted = 0') ->andWhere('nt.lang = :lang') ->setParameter('lang', $locale) - ->andWhere('nt.online = true') + ->andWhere('nt.online = 1') ->orderBy('nt.title', 'ASC'); if ($rootNode) { $qb->andWhere('n.lft >= :left') diff --git a/src/Kunstmaan/MenuBundle/Repository/MenuItemRepository.php b/src/Kunstmaan/MenuBundle/Repository/MenuItemRepository.php index 0c84cf2de6..39d0e39b1d 100644 --- a/src/Kunstmaan/MenuBundle/Repository/MenuItemRepository.php +++ b/src/Kunstmaan/MenuBundle/Repository/MenuItemRepository.php @@ -26,11 +26,11 @@ public function getMenuItemsForLanguage($menuName, $locale) ->setParameter('locale', $locale) ->andWhere('m.name = :name') ->setParameter('name', $menuName) - ->andWhere('nt.online = true OR mi.type = :url_type') + ->andWhere('nt.online = 1 OR mi.type = :url_type') ->setParameter('url_type', BaseMenuItem::TYPE_URL_LINK); $query = $query->getQuery(); - + return $query->getArrayResult(); } } diff --git a/src/Kunstmaan/NodeBundle/AdminList/NodeAdminListConfigurator.php b/src/Kunstmaan/NodeBundle/AdminList/NodeAdminListConfigurator.php index 12d913106d..1fe2d8bb53 100644 --- a/src/Kunstmaan/NodeBundle/AdminList/NodeAdminListConfigurator.php +++ b/src/Kunstmaan/NodeBundle/AdminList/NodeAdminListConfigurator.php @@ -243,7 +243,7 @@ public function adaptQueryBuilder(QueryBuilder $queryBuilder) ->select('b,n') ->innerJoin('b.node', 'n', 'WITH', 'b.node = n.id') ->andWhere('b.lang = :lang') - ->andWhere('n.deleted = false') + ->andWhere('n.deleted = 0') ->addOrderBy('b.updated', 'DESC') ->setParameter('lang', $this->locale); diff --git a/src/Kunstmaan/NodeBundle/Form/NodeChoiceType.php b/src/Kunstmaan/NodeBundle/Form/NodeChoiceType.php index e852520b9c..062044d9ca 100644 --- a/src/Kunstmaan/NodeBundle/Form/NodeChoiceType.php +++ b/src/Kunstmaan/NodeBundle/Form/NodeChoiceType.php @@ -49,7 +49,7 @@ public function configureOptions(OptionsResolver $resolver) ->innerJoin('nt.publicNodeVersion', 'nv') ->andWhere('nt.online = :online') ->andWhere('nt.lang = :lang') - ->andWhere('n.deleted != true') + ->andWhere('n.deleted != 1') ->andWhere('n.refEntityName IN(:refEntityName)') ->setParameter('lang', $options['locale'] ? $options['locale'] : $this->getCurrentLocale()) ->setParameter('refEntityName', $options['page_class']) diff --git a/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php b/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php index f2360bcfe6..c61f33f53e 100644 --- a/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php +++ b/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php @@ -74,7 +74,7 @@ public function getChildNodes( 'WITH', 't.publicNodeVersion = v.id' ) - ->where('b.deleted = false') + ->where('b.deleted = 0') ->setParameter('lang', $lang) ->addOrderBy('t.weight', 'ASC') ->addOrderBy('t.title', 'ASC'); @@ -283,8 +283,7 @@ public function getAllMenuNodes( case 'sqlite': $statement = 'CASE WHEN %s THEN %s ELSE %s END'; break; - case 'postgresql': - return sprintf('COALESCE(%s, %s)', $trueValue, $falseValue); + default: $statement = 'IF(%s, %s, %s)'; } @@ -296,7 +295,7 @@ public function getAllMenuNodes( n.id, n.parent_id AS parent, t.url, t.id AS nt_id, {$createIfStatement('t.weight IS NULL', 'v.weight', 't.weight')} AS weight, {$createIfStatement('t.title IS NULL', 'v.title', 't.title')} AS title, -t.online AS online, +{$createIfStatement('t.online IS NULL', '0', 't.online')} AS online, n.hidden_from_nav AS hidden, n.ref_entity_name AS ref_entity_name SQL; @@ -316,7 +315,7 @@ public function getAllMenuNodes( 'v', '(v.node_id = n.id AND v.lang <> :lang)' ) - ->where('n.deleted = false') + ->where('n.deleted = 0') ->addGroupBy('n.id') ->addOrderBy('t.weight', 'ASC') ->addOrderBy('t.title', 'ASC'); @@ -371,7 +370,7 @@ public function getAllParents(Node $node = null, $lang = null) 'WITH', 't.publicNodeVersion = v.id' ) - ->where('node.deleted = false'); + ->where('node.deleted = 0'); if ($lang) { $qb->andWhere('t.lang = :lang') @@ -415,7 +414,7 @@ public function getRootNodeFor(Node $node = null, $lang = null) 'WITH', 't.publicNodeVersion = v.id' ) - ->where('node.deleted = false') + ->where('node.deleted = 0') ->andWhere('node.parent IS NULL'); if ($lang) { @@ -447,7 +446,7 @@ public function getAllTopNodes() 'WITH', 't.publicNodeVersion = v.id' ) - ->where('b.deleted = false') + ->where('b.deleted = 0') ->andWhere('b.parent IS NULL'); $result = $qb->getQuery()->getResult(); @@ -480,7 +479,7 @@ public function getNodesByInternalName( 'WITH', 't.publicNodeVersion = v.id' ) - ->where('n.deleted = false') + ->where('n.deleted = 0') ->andWhere('n.internalName = :internalName') ->setParameter('internalName', $internalName) ->andWhere('t.lang = :lang') @@ -517,7 +516,7 @@ public function getNodeByInternalName($internalName) { $qb = $this->createQueryBuilder('n') ->select('n') - ->where('n.deleted = false') + ->where('n.deleted = 0') ->andWhere('n.internalName = :internalName') ->setParameter('internalName', $internalName); diff --git a/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php b/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php index 275bb05b90..ea3afd6b2c 100644 --- a/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php +++ b/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php @@ -29,8 +29,8 @@ public function getNodeTranslationByNodeIdQueryBuilder($nodeId, $lang) $qb = $this->createQueryBuilder('nt') ->select('nt') ->innerJoin('nt.node', 'n', 'WITH', 'nt.node = n.id') - ->where('n.deleted != true') - ->andWhere('nt.online = true') + ->where('n.deleted != 1') + ->andWhere('nt.online = 1') ->andWhere('nt.lang = :lang') ->setParameter('lang', $lang) ->andWhere('n.id = :node_id') @@ -240,7 +240,7 @@ private function getNodeTranslationForSlugPart( 'WITH', 't.publicNodeVersion = v.id' ) - ->where('n.deleted != true') + ->where('n.deleted != 1') ->setFirstResult(0) ->setMaxResults(1); @@ -298,7 +298,7 @@ public function getAllNodeTranslationsForUrl( ->setMaxResults(1); if (!$includeDeleted) { - $qb->andWhere('n.deleted = false'); + $qb->andWhere('n.deleted = 0'); } if (!empty($locale)) { @@ -375,7 +375,7 @@ public function getTopNodeTranslations() 'b.publicNodeVersion = v.id' ) ->where('n.parent IS NULL') - ->andWhere('n.deleted != true'); + ->andWhere('n.deleted != 1'); return $qb->getQuery()->getResult(); } @@ -503,7 +503,7 @@ public function getBestMatchForUrl($urlSlug, $locale) 'select nt.* from kuma_node_translations nt join kuma_nodes n on n.id = nt.node_id - where n.deleted = false and nt.lang = :lang and locate(nt.url, :url) = 1 + where n.deleted = 0 and nt.lang = :lang and locate(nt.url, :url) = 1 order by length(nt.url) desc limit 1', $rsm ); @@ -573,8 +573,8 @@ public function getNodeTranslationByLanguageAndInternalName( 'WITH', 'nt.publicNodeVersion = v.id' ) - ->where('n.deleted != true') - ->andWhere('nt.online = true') + ->where('n.deleted != 1') + ->andWhere('nt.online = 1') ->setFirstResult(0) ->setMaxResults(1); @@ -611,7 +611,7 @@ public function getParentNodeTranslation(NodeTranslation $nodeTranslation) ->innerJoin('nt.publicNodeVersion', 'nv') ->innerJoin('nt.node', 'n') ->where('nt.node = :parent') - ->andWhere('n.deleted = false') + ->andWhere('n.deleted = 0') ->andWhere('nt.lang = :lang') ->setParameter('parent', $parent) ->setParameter('lang', $nodeTranslation->getLang()); diff --git a/src/Kunstmaan/TranslatorBundle/AdminList/TranslationAdminListConfigurator.php b/src/Kunstmaan/TranslatorBundle/AdminList/TranslationAdminListConfigurator.php index 741a14308b..97932d4cbe 100644 --- a/src/Kunstmaan/TranslatorBundle/AdminList/TranslationAdminListConfigurator.php +++ b/src/Kunstmaan/TranslatorBundle/AdminList/TranslationAdminListConfigurator.php @@ -181,12 +181,9 @@ public function getQueryBuilder() $this->locales, $this->locales )); - $identifierQuoteCharacter = $this->connection->getDatabasePlatform()->getIdentifierQuoteCharacter(); - $quotedTextColumnName = $identifierQuoteCharacter . 'text' . $identifierQuoteCharacter; - // Add join for every locale foreach ($this->locales as $locale) { - $this->queryBuilder->addSelect('t_' . $locale . '.'.$quotedTextColumnName.' AS ' . $locale); + $this->queryBuilder->addSelect('t_' . $locale . '.`text` AS ' . $locale); $this->queryBuilder->addSelect('t_' . $locale . '.id AS ' . $locale . '_id'); $this->queryBuilder->leftJoin('b', 'kuma_translation', 't_' . $locale, 'b.keyword = t_' . $locale . '.keyword and b.domain = t_' . $locale . '.domain and t_' . $locale . '.locale=:locale_' . $locale); @@ -201,27 +198,27 @@ public function getQueryBuilder() $uniqueId = 'txt_' . $key; switch ($textComparator) { case 'equals': - $expr = $this->queryBuilder->expr()->eq('t_' . $locale . '.'.$quotedTextColumnName, ':var_' . $uniqueId); + $expr = $this->queryBuilder->expr()->eq('t_' . $locale . '.`text`', ':var_' . $uniqueId); $this->queryBuilder->setParameter('var_' . $uniqueId, $textValue); break; case 'notequals': - $expr = $this->queryBuilder->expr()->neq('t_' . $locale . '.'.$quotedTextColumnName, ':var_' . $uniqueId); + $expr = $this->queryBuilder->expr()->neq('t_' . $locale . '.`text`', ':var_' . $uniqueId); $this->queryBuilder->setParameter('var_' . $uniqueId, $textValue); break; case 'contains': - $expr = $this->queryBuilder->expr()->like('t_' . $locale . '.'.$quotedTextColumnName, ':var_' . $uniqueId); + $expr = $this->queryBuilder->expr()->like('t_' . $locale . '.`text`', ':var_' . $uniqueId); $this->queryBuilder->setParameter('var_' . $uniqueId, '%' . $textValue . '%'); break; case 'doesnotcontain': - $expr = 't_' . $locale . '.'.$quotedTextColumnName . ' NOT LIKE :var_' . $uniqueId; + $expr = 't_' . $locale . '.`text`' . ' NOT LIKE :var_' . $uniqueId; $this->queryBuilder->setParameter('var_' . $uniqueId, '%' . $textValue . '%'); break; case 'startswith': - $expr = $this->queryBuilder->expr()->like('t_' . $locale . '.'.$quotedTextColumnName, ':var_' . $uniqueId); + $expr = $this->queryBuilder->expr()->like('t_' . $locale . '.`text`', ':var_' . $uniqueId); $this->queryBuilder->setParameter('var_' . $uniqueId, $textValue . '%'); break; case 'endswith': - $expr = $this->queryBuilder->expr()->like('t_' . $locale . '.'.$quotedTextColumnName, ':var_' . $uniqueId); + $expr = $this->queryBuilder->expr()->like('t_' . $locale . '.`text`', ':var_' . $uniqueId); $this->queryBuilder->setParameter('var_' . $uniqueId, '%' . $textValue); break; } diff --git a/src/Kunstmaan/TranslatorBundle/Repository/TranslationRepository.php b/src/Kunstmaan/TranslatorBundle/Repository/TranslationRepository.php index 33d1f35413..0e8c9ae00f 100644 --- a/src/Kunstmaan/TranslatorBundle/Repository/TranslationRepository.php +++ b/src/Kunstmaan/TranslatorBundle/Repository/TranslationRepository.php @@ -32,7 +32,7 @@ public function getLastChangedTranslationDate() $sql = <<getClassMetaData('KunstmaanTranslatorBundle:Translation')->getTableName(); @@ -51,7 +51,7 @@ public function getLastChangedTranslationDate() $result = $stmt->fetch(); if (is_array($result) && count($result) > 0) { - return new \DateTime($result['newest_date']); + return new \DateTime($result['newestDate']); } return null; From 846093f85b14c64a8eaf7810211ccb7476d2e24c Mon Sep 17 00:00:00 2001 From: Sander Goossens Date: Tue, 6 Feb 2018 18:25:36 +0100 Subject: [PATCH 2/4] [KunstmaanAdminBundle] change php7 to php5 code (#1807) --- src/Kunstmaan/AdminBundle/EventListener/ToolbarListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Kunstmaan/AdminBundle/EventListener/ToolbarListener.php b/src/Kunstmaan/AdminBundle/EventListener/ToolbarListener.php index 2705618803..b01a493ef7 100644 --- a/src/Kunstmaan/AdminBundle/EventListener/ToolbarListener.php +++ b/src/Kunstmaan/AdminBundle/EventListener/ToolbarListener.php @@ -84,7 +84,7 @@ public function __construct( DataCollector $dataCollector, AuthorizationChecker $authorizationChecker, TokenStorageInterface $tokenStorage, - bool $enabled, + $enabled, ContainerInterface $container, AdminRouteHelper $adminRouteHelper, array $providerKeys From 8e982e2926a807c787a84f90767a8bc3372b0ac9 Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Tue, 6 Feb 2018 21:23:51 +0100 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2437b38bd9..29a0127985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 4.1.3 / 2018-02-06 + +* [AllBundles] Revert "Postgres compatibility fixes (#1778)" [#1810](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/1810) ([@sandergo90](https://github.com/sandergo90)) + + ## 4.1.2 / 2018-02-02 * [AdminBundle] fixed z-index of modal [#1805](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/1805) ([@deZinc](https://github.com/deZinc)) From 15f2d2b1f076fbca265789fdf541d6fe677c1a62 Mon Sep 17 00:00:00 2001 From: Ruud Denivel Date: Tue, 6 Feb 2018 21:36:45 +0100 Subject: [PATCH 4/4] update changelog --- CHANGELOG-5.X.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG-5.X.md b/CHANGELOG-5.X.md index a974bb0a52..b9e9fbee9a 100644 --- a/CHANGELOG-5.X.md +++ b/CHANGELOG-5.X.md @@ -1,5 +1,10 @@ # Changelog +## 5.0.3 / 2018-02-06 + +* [KunstmaanAdminBundle] change php7 to php5 code [#1807](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/1807) ([@sandergo90](https://github.com/sandergo90)) + + ## 5.0.2 / 2018-02-05 * [KunstmaanAdminBundle]: rebuild styling [#1806](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/1806) ([@sandergo90](https://github.com/sandergo90))