Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

disable FOREIGN_KEY_CHECKS on MySQL #115

Closed
wants to merge 5 commits into from

2 participants

@havvg
Collaborator

I'm not exactly sure on this. We had the issue when using the DataLoader in setUp of tests that it could not delete entries. This is an issue of every data loader. We currently solved it, by adding the DataWiper before actually loading expected fixtures for the tests.

I think it makes sense to disable the checks here, too.

@willdurand
Owner

mmh, shouldn't Propel take care of that? Using InnoDB as engine if I remember well

@havvg
Collaborator

We use InnoDB, but it causes a foreign key constraints error.

I will setup a testcase, so we can verify why and where exactly it breaks.

@willdurand
Owner

@havvg poke ?

@havvg
Collaborator

Sorry, I have to postpone this one, very busy days. I can't tell, when I will be able to provide the testcase.

@willdurand
Owner

There is no problem ;)

@willdurand
Owner

@havvg any news?

@havvg
Collaborator

We are currently on this issue, hopefully we will catch the root cause and provide a fix + tests this week.

@havvg
Collaborator

We added the DataWiper to our testsuite, so it's fine without this change.

However the propel:fixtures:load command does not work without it, if you split up related fixtures in their respective files.
In that case, you have to disable the FK checks, so you can modify the database with all files found one by one.

Another solution would be to merge all found files into one prior actually working down the fixtures content.

<?php
    public function load($files = array(), $connectionName)
    {
            // ..

            $this->con->beginTransaction();

            $datas = array();
            foreach ($files as $file) {
                $content = $this->transformDataToArray($file);

                if (count($content) > 0) {
                    $datas = array_merge($datas, $content);
                    $nbFiles++;
                }
            }

            $this->deleteCurrentData($datas);
            $this->loadDataFromArray($datas);

            $this->con->commit();

            // ..

I would prefer this solution, as it is more generic than adding mysql specific logic.
Let me know, what you think and adjust the PR! @willdurand

@havvg
Collaborator

I mean, I'll adjust the PR :)

@willdurand
Owner

@havvg to merge fixtures is fine, right? I mean it's the most convenient solution IMO

@havvg
Collaborator

Yep, that's what I'm thinking, too. I'll update this PR soon.

@havvg havvg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 24, 2012
  1. @willdurand

    Fixed README

    willdurand authored
  2. @willdurand
  3. @havvg
  4. @willdurand

    Merge pull request #144 from havvg/master

    willdurand authored
    fix SecurityIdentity username with multiple dashes
Commits on May 2, 2012
  1. @havvg
This page is out of date. Refresh to see the latest.
View
11 DataFixtures/Loader/AbstractDataLoader.php
@@ -60,16 +60,19 @@ public function load($files = array(), $connectionName)
try {
$this->con->beginTransaction();
+ $datas = array();
foreach ($files as $file) {
- $datas = $this->transformDataToArray($file);
+ $content = $this->transformDataToArray($file);
- if (count($datas) > 0) {
- $this->deleteCurrentData($datas);
- $this->loadDataFromArray($datas);
+ if (count($content) > 0) {
+ $datas = array_merge($datas, $content);
$nbFiles++;
}
}
+ $this->deleteCurrentData($datas);
+ $this->loadDataFromArray($datas);
+
$this->con->commit();
} catch (\Exception $e) {
$this->con->rollBack();
View
2  Model/Acl/SecurityIdentity.php
@@ -34,7 +34,7 @@ static public function toAclIdentity(SecurityIdentity $securityIdentity)
throw new \InvalidArgumentException('The given identifier does not resolve to a UserSecurityIdentity.');
}
- list($class, $username) = explode('-', $identifier);
+ list($class, $username) = explode('-', $identifier, 2);
return new UserSecurityIdentity($username, $class);
}
View
2  README.markdown
@@ -20,7 +20,7 @@ As `Propel2` will be released in the near future, we are migrating the branching
* If you depend on the `master` branch, switch to the `1.1` branch.
* If you depend on the `2.0` branch, switch to the `1.0` branch.
-We will keep all branches in sync until `Propel2` will be released.
+**Note:** the `master`, and `2.0` branches won't be updated anymore, and will trigger a `E_USER_DEPRECATED` error to notice people.
## Features
View
13 Tests/Model/Acl/SecurityIdentityTest.php
@@ -54,6 +54,17 @@ public function testToAclIdentityValidUser()
$this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\UserSecurityIdentity', $secIdentity);
}
+ public function testToAclIdentityMultipleDashes()
+ {
+ $identity = new SecurityIdentity();
+ $identity->setIdentifier('Propel\PropelBundle\Tests\Fixtures\UserProxy-some-username@domain.com');
+ $identity->setUsername(true);
+
+ $secIdentity = SecurityIdentity::toAclIdentity($identity);
+ $this->assertInstanceOf('Symfony\Component\Security\Acl\Domain\UserSecurityIdentity', $secIdentity);
+ $this->assertEquals('some-username@domain.com', $secIdentity->getUsername());
+ }
+
public function testToAclIdentityValidRole()
{
$identity = new SecurityIdentity();
@@ -108,4 +119,4 @@ public function testFromAclIdentityWithRole()
$dbEntry = SecurityIdentityQuery::create()->findPk($identity->getId());
$this->assertInstanceOf('Propel\PropelBundle\Model\Acl\SecurityIdentity', $dbEntry);
}
-}
+}
View
3  composer.json
@@ -13,8 +13,7 @@
"propel/propel1": "1.6.*"
},
"require-dev": {
- "sensio/framework-extra-bundle": "*",
- "twig/twig": "1.7.*"
+ "sensio/framework-extra-bundle": "*"
},
"autoload": {
"psr-0": { "Propel\\PropelBundle": "" }
Something went wrong with that request. Please try again.