-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[All Bundles] Added PostgreSQL support #2811
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f89df38
quote strings by char which is provided by the database platform
igst 3195b72
cast ACL varchar column to int when joining with int
igst 163b8e8
use strict bool values instead of int
igst ec7c7bf
Removed unnecessary databasePrefix
igst 21c6f20
Removed unnecessary double escaping - only required in like statements
igst f6e241c
add test for AbstractPlatform::getStringLiteralQuoteCharacter()
igst d631126
use setParameter() with boolean values for boolean database columns
igst 98f4421
use CASE WHEN if database platform is postgresql
igst 96cda12
quote reserved column name "text" with quote chars provided by databa…
igst 59f2526
removed unnecessary order‹by clause for one numeric result which brok…
igst 8888ac2
fix cs
igst 9ef0b19
fixed tests
igst 838f4ba
use Statement::bindValue instead of QueryBuilder::setParameter
igst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,14 +67,14 @@ public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissi | |
} | ||
|
||
$aclConnection = $this->em->getConnection(); | ||
$stringQuoteChar = $aclConnection->getDatabasePlatform()->getStringLiteralQuoteCharacter(); | ||
|
||
$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(); | ||
|
||
$rootEntity = '"' . str_replace('\\', '\\\\', $rootEntity) . '"'; | ||
$rootEntity = $stringQuoteChar . $rootEntity . $stringQuoteChar; | ||
$query = $queryBuilder; | ||
|
||
$builder = new MaskBuilder(); | ||
|
@@ -99,40 +99,41 @@ public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissi | |
} | ||
|
||
// Security context does not provide anonymous role automatically. | ||
$uR = array('"IS_AUTHENTICATED_ANONYMOUSLY"'); | ||
$uR = array($stringQuoteChar . 'IS_AUTHENTICATED_ANONYMOUSLY' . $stringQuoteChar); | ||
|
||
foreach ($userRoles as $role) { | ||
// The reason we ignore this is because by default FOSUserBundle adds ROLE_USER for every user | ||
if (is_string($role)) { | ||
if ($role !== 'ROLE_USER') { | ||
$uR[] = '"' . $role . '"'; | ||
$uR[] = $stringQuoteChar . $role . $stringQuoteChar; | ||
} | ||
} else { | ||
// Symfony 3.4 compatibility | ||
if ($role->getRole() !== 'ROLE_USER') { | ||
$uR[] = '"' . $role->getRole() . '"'; | ||
$uR[] = $stringQuoteChar . $role->getRole() . $stringQuoteChar; | ||
} | ||
} | ||
} | ||
$uR = array_unique($uR); | ||
$inString = implode(' OR s.identifier = ', $uR); | ||
|
||
if (\is_object($user)) { | ||
$inString .= ' OR s.identifier = "' . str_replace( | ||
'\\', | ||
'\\\\', | ||
\get_class($user) | ||
) . '-' . $user->getUserName() . '"'; | ||
$inString .= ' OR s.identifier = ' . $stringQuoteChar . \get_class($user) . '-' . $user->getUserName() . $stringQuoteChar; | ||
} | ||
|
||
$objectIdentifierColumn = 'o.object_identifier'; | ||
if ($aclConnection->getDatabasePlatform()->getName() === 'postgresql') { | ||
$objectIdentifierColumn = 'o.object_identifier::BIGINT'; | ||
} | ||
|
||
$joinTableQuery = <<<SELECTQUERY | ||
SELECT DISTINCT o.object_identifier as id FROM {$databasePrefix}acl_object_identities as o | ||
INNER JOIN {$databasePrefix}acl_classes c ON c.id = o.class_id | ||
LEFT JOIN {$databasePrefix}acl_entries e ON ( | ||
SELECT DISTINCT {$objectIdentifierColumn} as id FROM acl_object_identities as o | ||
INNER JOIN acl_classes c ON c.id = o.class_id | ||
LEFT JOIN acl_entries e ON ( | ||
e.class_id = o.class_id AND (e.object_identity_id = o.id | ||
OR {$aclConnection->getDatabasePlatform()->getIsNullExpression('e.object_identity_id')}) | ||
) | ||
LEFT JOIN {$databasePrefix}acl_security_identities s ON ( | ||
LEFT JOIN acl_security_identities s ON ( | ||
s.id = e.security_identity_id | ||
) | ||
WHERE c.class_type = {$rootEntity} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question as comment above |
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,8 +41,10 @@ class {{ entity_class }}PageRepository extends AbstractArticlePageRepository | |
->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('t.online = 1') | ||
->andWhere('n.deleted = 0') | ||
->where('t.online = :online') | ||
->setParameter('online', true) | ||
->andWhere('n.deleted = :deleted') | ||
->setParameter('deleted', false) | ||
->andWhere('v.refEntityName = :refname') | ||
->orderBy('a.date', 'DESC') | ||
->setParameter('refname', "{{ namespace | replace({'\\': '\\\\'}) }}\\Entity\\Pages\\{{ entity_class }}Page"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. //// is only required in LIKE clause and should not work with "=" |
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need quotes here? https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/1778/files#diff-2ae42119f573a6a61e26009641aa186d97e0f77b951dc02385d67d9daa075854R193