From b20b15bd4cb53291a6775b08319f15c5d0a1b113 Mon Sep 17 00:00:00 2001 From: Gustavo Piltcher Date: Wed, 23 Nov 2011 19:02:00 -0200 Subject: [PATCH] Oracle 10 issues I've changed Schema.php to not use Restrict on delete/update since oracle report it as missing keyword. Both restrict and no action on oracle seems to be redundant and used by default. So the output query can't use it. I've also changed Schema construct to accept a SchemaConfig parameter. InitAcl was changed to pass on new Schema a SchemaConfig generated by SchemaManager, I did that because acl command was generating names with more than 30 characters and Oracle doesn't accept, this seems to solve the problem and init:acl works properly. --- .../SecurityBundle/Command/InitAclCommand.php | 9 +++++---- .../Component/Security/Acl/Dbal/Schema.php | 20 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php index 3fd12b42b7..fcef6772e0 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php @@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Security\Acl\Dbal\Schema; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Doctrine\DBAL\DriverManager; /** * Installs the tables required by the ACL system @@ -34,7 +35,7 @@ class InitAclCommand extends ContainerAwareCommand ->setHelp(<<init:acl command mounts ACL tables in the database. -php app/console init:acl +php app/console ini:acl The name of the DBAL connection must be configured in your app/config/security.yml configuration file in the security.acl.connection variable. @@ -68,12 +69,12 @@ EOT return; } } - - $schema = new Schema($tables); + + $schema = new Schema($tables, null, $sm->createSchemaConfig()); foreach ($schema->toSql($connection->getDatabasePlatform()) as $sql) { $connection->exec($sql); } $output->writeln('ACL tables have been initialized successfully.'); } -} +} \ No newline at end of file diff --git a/src/Symfony/Component/Security/Acl/Dbal/Schema.php b/src/Symfony/Component/Security/Acl/Dbal/Schema.php index 97372f0ab5..15cb9c7be4 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/Schema.php +++ b/src/Symfony/Component/Security/Acl/Dbal/Schema.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Security\Acl\Dbal; use Doctrine\DBAL\Schema\Schema as BaseSchema; +use Doctrine\DBAL\Schema\SchemaConfig as SchemaConfig; /** * The schema used for the ACL system. @@ -26,10 +27,11 @@ final class Schema extends BaseSchema * Constructor * * @param array $options the names for tables + * @return void */ - public function __construct(array $options) + public function __construct(array $options, $unused=null, SchemaConfig $schemaConfig=null) { - parent::__construct(); + parent::__construct(array(), array(), $schemaConfig); $this->options = $options; @@ -42,6 +44,8 @@ final class Schema extends BaseSchema /** * Adds the class table to the schema + * + * @return void */ protected function addClassTable() { @@ -54,6 +58,8 @@ final class Schema extends BaseSchema /** * Adds the entry table to the schema + * + * @return void */ protected function addEntryTable() { @@ -82,6 +88,8 @@ final class Schema extends BaseSchema /** * Adds the object identity table to the schema + * + * @return void */ protected function addObjectIdentitiesTable() { @@ -97,11 +105,13 @@ final class Schema extends BaseSchema $table->addUniqueIndex(array('object_identifier', 'class_id')); $table->addIndex(array('parent_object_identity_id')); - $table->addForeignKeyConstraint($table, array('parent_object_identity_id'), array('id'), array('onDelete' => 'RESTRICT', 'onUpdate' => 'RESTRICT')); + $table->addForeignKeyConstraint($table, array('parent_object_identity_id'), array('id')); } /** * Adds the object identity relation table to the schema + * + * @return void */ protected function addObjectIdentityAncestorsTable() { @@ -119,6 +129,8 @@ final class Schema extends BaseSchema /** * Adds the security identity table to the schema + * + * @return void */ protected function addSecurityIdentitiesTable() { @@ -131,4 +143,4 @@ final class Schema extends BaseSchema $table->setPrimaryKey(array('id')); $table->addUniqueIndex(array('identifier', 'username')); } -} +} \ No newline at end of file