This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » symfony 1.3 and 1.4 » [SOLVED] sfDoctrineGuardPlugin - Error during data-load
[SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #92047] Fri, 22 January 2010 16:10 Go to next message
Choup  is currently offline Choup
Messages: 9
Registered: January 2010
Location: France
Junior Member
Hello,

I've a problem with the plugin sfDoctrineGuardPlugin. I have follow the readme of the plugin ( http://www.symfony-project.org/plugins/sfdoctrineGuardPlugin ) and all seems to be ok.
I was able to be authentify with the admin user, and use my modules. But when i've tried to create a relation into my table 'personne' with the table 'sfGuardUser' that become dramatic.

I've create a foreign key 'user_id' in 'personne' which references to 'id' in the table 'sfGuardUser'. After that, impossible to do a ./symfony doctrine:data-load task correctly :
>> doctrine  Loading data fixtures from "/hom...eon/Intranet-CCTB/data/fixtures"
>> doctrine  Loading data fixtures from "/hom...ctrineGuardPlugin/data/fixtures"

                                                                                          
  Unknown record property / related component "sfguardgroup" on "sfGuardGroupPermission"


And then nothing is add in my database, even if i change the data which sould be added, if i delete the admin data in my database, and even if i delete the foreign key relation .

My data/fixtures/sfGuard.yml is :
sfGuardUser:
  sgu_admin:
    username:       admin
    password:       admin
    is_super_admin: true

sfGuardPermission:
  sgp_admin:
    name:           admin
    description:    Administrator permission

sfGuardGroup:
  sgg_admin:
    name:           admin
    description:    Administrator group

sfGuardGroupPermission:
  sggp_admin:
    sfGuardGroup:       sgg_admin
    sfGuardPermission:  sgp_admin

sfGuardUserGroup:
  sgug_admin:
    sfGuardGroup:       sgg_admin
    sfGuardUser:        sgu_admin


So if someone could save me ... Smile

[Updated on: Tue, 26 January 2010 09:10]

Re: sfDoctrineGuardPlugin - Error during data-load [message #92053 is a reply to message #92047 ] Fri, 22 January 2010 17:40 Go to previous messageGo to next message
hasc  is currently offline hasc
Messages: 195
Registered: October 2007
Senior Member
never worked witth doctrine but i think you have to use the name of the column not the class name.
sfGuardGroupPermission:
  sggp_admin:
    sf_guard_group_id:       sgg_admin
    sf_guard_permission_id:  sgp_admin

sfGuardUserGroup:
  sgug_admin:
    sf_guard_group_id:       sgg_admin
    sf_guard_user_id:        sgu_admin

regards,
hasc
Re: sfDoctrineGuardPlugin - Error during data-load [message #92055 is a reply to message #92053 ] Fri, 22 January 2010 17:56 Go to previous messageGo to next message
Choup  is currently offline Choup
Messages: 9
Registered: January 2010
Location: France
Junior Member
the class name are native from plugins/sfDoctrineGuardPlugin/data/fixtures/fixtures.yml.sam ple

I've changed my sfGuard.yml, try a load and the error seems to be similar :
>> doctrine  Loading data fixtures from "/hom...eon/Intranet-CCTB/data/fixtures"
>> doctrine  Loading data fixtures from "/hom...ctrineGuardPlugin/data/fixtures"

                                                                                               
  Unknown record property / related component "sf_guard_group_id" on "sfGuardGroupPermission"  
                                       


Nota Bene : i've try again whith only a 'personne' and a 'sfGuardUser' :
sfGuardUser:
 sgu_admin:
    username:       admin
    password:       admin
    is_super_admin: true


personne:
  p_people:
    nom:         lapointe
    prenom:      bobby
    SfGuardUser: sgu_admin
    


./symfony doctrine:data-load and ... that work

Look like the problem is locate with the sfDoctrineGuardPlugin tables.
Re: sfDoctrineGuardPlugin - Error during data-load [message #92056 is a reply to message #92055 ] Fri, 22 January 2010 18:01 Go to previous messageGo to next message
hasc  is currently offline hasc
Messages: 195
Registered: October 2007
Senior Member
hm sorry, as i said i never worked with symfony. maybe someone else can help.
Re: sfDoctrineGuardPlugin - Error during data-load [message #92103 is a reply to message #92047 ] Sun, 24 January 2010 11:15 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Didn't you use the "symfony doctrine:build-schema" task? If so you have now in your project schema.yml the sfDoctrineGuardPlugin tables configuration and this is the problem.

[Updated on: Sun, 24 January 2010 11:16]

Re: sfDoctrineGuardPlugin - Error during data-load [message #92139 is a reply to message #92103 ] Mon, 25 January 2010 09:15 Go to previous messageGo to next message
Choup  is currently offline Choup
Messages: 9
Registered: January 2010
Location: France
Junior Member
tomor

Didn't you use the "symfony doctrine:build-schema" task?

I use this task.
I do these tasks :
symfony doctrine:build-schema
symfony doctrine:build-model
symfony doctrine:build-sql
symfony doctrine:insert-sql


(before my problem)

hasc

hm sorry, as i said i never worked with symfony

No problem, thanks for your try =)

Edit :
It look like the first letter have to be a capital letter :
sfGuardUser:
  sgu_admin:
    username:       admin
    password:       admin
    is_super_admin: true

personne:
  pers_1:
   nom: girousse
   prenom: simeon
   SfGuardUser: sgu_admin

sfGuardPermission:
  sgp_admin:
    name:           admin
    description:    Administrator permission

sfGuardUserGroup:
  sgug_admin:
      SfGuardGroup: sgg_admin
      SfGuardUser: sgu_admin

sfGuardGroup:
  sgg_admin:
    name:          admin
    description:    Administrator group

sfGuardGroupPermission:
  sggp_admin:
    SfGuardGroup:       sgg_admin
    SfGuardPermission:  sgp_admin


Now the data are correctly saved except for the sfGuardGroupPermission, and i've an error :
>> doctrine  Loading data fixtures from "/hom...eon/Intranet-CCTB/data/fixtures"
>> doctrine  Loading data fixtures from "/hom...ctrineGuardPlugin/data/fixtures"

                                                                                     
  Unknown record property / related component "sf_guard_user" on "sfGuardUserGroup"  


The sfGuardUser link seems to work well in my table 'personne' but not with 'sf_guard_group_permission' ...

[Updated on: Mon, 25 January 2010 11:55]

Re: sfDoctrineGuardPlugin - Error during data-load [message #92153 is a reply to message #92047 ] Mon, 25 January 2010 12:46 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Ok, I think you problem is this:

During symfony doctrine:build-schema task you loaded a whole database into your config/doctrine/schema.yml ... your tables, and all sfGuard tables. But the sfGuard tables are already defined in the plugin schema file: plugins/sfDoctrineGuardPlugin/config/doctrine/schema.yml

So now you have this tables defined twice, and I think that in your project schema file (config/doctrine/schema.yml) it was from some reason created badly (symfony doctrine:build-schema did that - not your falt).

So the solution is to remove all definitions of the sfDoctrineGuard tables from your project schema file (config/doctrine/schema.yml), and let them only in the plugin schema file.

Then you can use right fixtures for the sfDoctrineGuard - without cappital letters:

sfGuardUser:
  sgu_admin:
    username:       admin
    password:       admin
    is_super_admin: true

sfGuardPermission:
  sgp_admin:
    name:           admin
    description:    Administrator permission

sfGuardGroup:
  sgg_admin:
    name:           admin
    description:    Administrator group

sfGuardGroupPermission:
  sggp_admin:
    sfGuardGroup:       sgg_admin
    sfGuardPermission:  sgp_admin

sfGuardUserGroup:
  sgug_admin:
    sfGuardGroup:       sgg_admin
    sfGuardUser:        sgu_admin
Re: sfDoctrineGuardPlugin - Error during data-load [message #92159 is a reply to message #92153 ] Mon, 25 January 2010 13:42 Go to previous messageGo to next message
Choup  is currently offline Choup
Messages: 9
Registered: January 2010
Location: France
Junior Member
I have remove all definitions of the sfDoctrineGuard tables from my project schema file, and re-insert my sql. All was ok, but when i've tried to insert the fixtures, it was the same error message... (i have try with and without the capital letters, after a drop database and a ./symfony cc, checked my schema.yml, etc)

With your solution it's one other problem, the link into my table 'personne' and the plugin's table 'sf_guard_user' doesn't exist.
But even if i remove data about 'personne', i have always a problem with the 'sf_guard_user_group'

(cf err message in my previous post)
Re: sfDoctrineGuardPlugin - Error during data-load [message #92160 is a reply to message #92047 ] Mon, 25 January 2010 13:52 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Ok, try to run symfony doctrine:build --all --and-load --no-confirmation task.

If this doesn't help post here content of

config/doctrine/schema.yml
plugins/sfDoctrineGuardPlugin/config/doctrine/schema.yml
data/fixtures/*.*

And look what you have in
plugins/sfDoctrineGuardPlugin/data/fixtures/
Re: sfDoctrineGuardPlugin - Error during data-load [message #92163 is a reply to message #92160 ] Mon, 25 January 2010 14:39 Go to previous messageGo to next message
Choup  is currently offline Choup
Messages: 9
Registered: January 2010
Location: France
Junior Member
tomor

Ok, try to run symfony doctrine:build --all --and-load --no-confirmation task.


Almost ok ^^'

Everything look to work, but if i had a 'personne' in my sfGuard.yml, te link is not found.
And why the ./symfony doctrine:data-load task doesn't work, but ./symfony doctrine:build --all --and-load --no-confirmation yes ? i have miss something ?

So that are my files :

(i've spoil them because there are a little too long for a post)
Toggle Spoiler


In plugins/sfDoctrineGuardPlugin/data/fixtures/, i have fixtures.yml.sample (sfGuard.yml is a copy of this file, without 'personne' ...)
Re: sfDoctrineGuardPlugin - Error during data-load [message #92167 is a reply to message #92163 ] Mon, 25 January 2010 15:07 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Choup wrote on Mon, 25 January 2010 14:39

And why the ./symfony doctrine:data-load task doesn't work, but ./symfony doctrine:build --all --and-load --no-confirmation yes ? i have miss something ?


doctrine:build --all --and-load --no-confirmation task don't start the symfony doctrine:build-schema task - it won't break your project schema file with the sfGuard schema. It does all other tasks .. you can find them e.g. in Day 3 - Practical symfony jobeet 1.4 doctrine, or some other manual.

Choup wrote on Mon, 25 January 2010 14:39


Everything look to work, but if i had a 'personne' in my sfGuard.yml, te link is not found.


This problem is because you haven't a relation between a persone and sfGuardUser

you need to modify your project schema file little bit:

Add this line into your /config/schema.yml to the persone relations definition part...

sfGuardUser: { local: sf_guard_user_id, foreign: id, foreignType: one }


So the persone relations definition will look like this:
  relations:
    sfGuardUser:
      local: sf_guard_user_id
      foreign: id
      foreignType: one
    Adresse:
      local: id
      foreign: personne_id
      type: many
    ContactPro:
      local: id
      foreign: personne_id
      type: many
    Fax:
      local: id
      foreign: personne_id
      type: many
    Mail:
      local: id
      foreign: personne_id
      type: many
    Telephone:
      local: id
      foreign: personne_id
      type: many


Run the symfony doctrine:build --all --and-load --no-confirmation and it should work Wink
Re: sfDoctrineGuardPlugin - Error during data-load [message #92174 is a reply to message #92167 ] Mon, 25 January 2010 15:57 Go to previous messageGo to next message
Choup  is currently offline Choup
Messages: 9
Registered: January 2010
Location: France
Junior Member
Hum i have add the sfGuardUser line ( sfGuardUser: { local: sf_guard_user_id, foreign: id, foreignType: one } ) and that work, but now i have that error :

  Unknown record property / related component "sfguardgroup" on "SfGuardUserGroup" 


Return at my first error Sad


(And thanks for your help, i am a little desperate ^^')
Re: sfDoctrineGuardPlugin - Error during data-load [message #92178 is a reply to message #92174 ] Mon, 25 January 2010 16:08 Go to previous messageGo to next message
Choup  is currently offline Choup
Messages: 9
Registered: January 2010
Location: France
Junior Member
Sorry for the double-post, but that's work !! Smile

I've to set the capital letters in my data/fixtures/sfGuard.yml (there are capital letters in the schema.yml)

The first error was about the double plugin tables definition, the second about the line in 'personne' and the last about the capital letters.

Thanks for all
Re: sfDoctrineGuardPlugin - Error during data-load [message #92179 is a reply to message #92174 ] Mon, 25 January 2010 16:09 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
The first error was
Unknown record property / related component "sfguardgroup" on "sfGuardGroupPermission"

so this is a progress Wink
Re: sfDoctrineGuardPlugin - Error during data-load [message #92180 is a reply to message #92178 ] Mon, 25 January 2010 16:12 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Choup wrote on Mon, 25 January 2010 16:08

Sorry for the double-post, but that's work !! Smile

I've to set the capital letters in my data/fixtures/sfGuard.yml (there are capital letters in the schema.yml)

The first error was about the double plugin tables definition, the second about the line in 'personne' and the last about the capital letters.

Thanks for all


Great, I'm glad it works Wink
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95613 is a reply to message #92047 ] Wed, 17 March 2010 11:33 Go to previous messageGo to next message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
Hi everybody,

I am sorry to reopen this case but I have just encountered the same problem:

I just use symfony doctrine:data-load with the following test.yml
sfGuardGroup:
  gTest:
    name: groupe test

sfGuardUser:
  toto:
    username: toto
    password: t0t0
  Titi:
    username: titi
    password: t1t1
  Tata:
    username: tata
    password: t4t4

sfGuardUserGroup:
  ug1:
    sfGuardGroup: gTest
    sfGuardUser:  toto


and I get the following error:
Unknown record property / related component "sfgardgroup" on sgGuardUserGroup


So I used the capital letters trick and tried with this file:
sfGuardGroup:
  gTest:
    name: groupe test

sfGuardUser:
  toto:
    username: toto
    password: t0t0
  Titi:
    username: titi
    password: t1t1
  Tata:
    username: tata
    password: t4t4

sfGuardUserGroup:
  ug1:
    SfGuardGroup: gTest
    SfGuardUser:  toto

The "sfguardgroup" error has disappeared but a "sf_guard_user" error is now displayed. I tried with sfGuardUser instead of SfGuardUser but it only changes the error from "sf_guard_user" to "sfguarduser".

I let symfony user the shema.yml from the plugin sfGuard for this tables.

If any coul help, thanks a lot.
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95618 is a reply to message #92047 ] Wed, 17 March 2010 12:07 Go to previous messageGo to next message
Levelx  is currently offline Levelx
Messages: 358
Registered: April 2009
Location: Germany
Faithful Member
Maybe you think too complicated Smile

Try it this way:

sfGuardGroup:
    group_1:
        name: name1
        
    group_2:
        name: name2
        
sfGuardUser:
    my_test_user01:
        username:       toto
        password:       secret
        groups:         [group_1, group_2] 
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95624 is a reply to message #92047 ] Wed, 17 March 2010 13:47 Go to previous messageGo to next message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
This solution does not work even with "Groups" instead of "groups".

Here is my schema.yml from the sfDoctrineGuard Plugin
sfGuardGroup:
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    name:
      type: string(255)
      unique: true
    description: string(1000)
  relations:
    users:
      class: sfGuardUser
      refClass: sfGuardUserGroup
      local: group_id
      foreign: user_id
      foreignAlias: Groups
    permissions:
      class: sfGuardPermission
      local: group_id
      foreign: permission_id
      refClass: sfGuardGroupPermission
      foreignAlias: Groups

sfGuardPermission:
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    name:
      type: string(255)
      unique: true
    description: string(1000)

sfGuardGroupPermission:
  options:
    symfony:
      form:   false
      filter: false
  actAs: [Timestampable]
  columns:
    group_id:
      type: integer(4)
      primary: true
    permission_id:
      type: integer(4)
      primary: true
  relations:
    sfGuardGroup:
      local: group_id
      onDelete: CASCADE
    sfGuardPermission:
      local: permission_id
      onDelete: CASCADE

sfGuardUser:
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    username:
      type: string(128)
      notnull: true
      unique: true
    algorithm:
      type: string(128)
      default: sha1
      notnull: true
    salt: string(128)
    password: string(128)
    is_active:
      type: boolean
      default: 1
    is_super_admin:
      type: boolean
      default: false
    last_login:
      type: timestamp
  indexes:
    is_active_idx:
      fields: [is_active]
  relations:
    groups:
      class: sfGuardGroup
      local: user_id
      foreign: group_id
      refClass: sfGuardUserGroup
      foreignAlias: Users
    permissions:
      class: sfGuardPermission
      local: user_id
      foreign: permission_id
      refClass: sfGuardUserPermission
      foreignAlias: Users

sfGuardUserPermission:
  options:
    symfony:
      form:   false
      filter: false
  actAs: [Timestampable]
  columns:
    user_id:
      type: integer(4)
      primary: true
    permission_id:
      type: integer(4)
      primary: true
  relations:
    sfGuardUser:
      local: user_id
      onDelete: CASCADE
    sfGuardPermission:
      local: permission_id
      onDelete: CASCADE

sfGuardUserGroup:
  options:
    symfony:
      form:   false
      filter: false
  actAs: [Timestampable]
  columns:
    user_id:
      type: integer(4)
      primary: true
    group_id:
      type: integer(4)
      primary: true
  relations:
    sfGuardUser:
      local: user_id
      onDelete: CASCADE
    sfGuardGroup:
      local: group_id
      onDelete: CASCADE

sfGuardRememberKey:
  options:
    symfony:
      form:   false
      filter: false
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    user_id:
      type: integer(4)
    remember_key: string(32)
    ip_address:
      type: string(50)
      primary: true
  relations:
    sfGuardUser:
      local: user_id
      foreignAlias: RememberKeys
      foreignType: one
      onDelete: CASCADE


I really don't get what's wrong...

[Updated on: Wed, 17 March 2010 16:42]

Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95625 is a reply to message #92047 ] Wed, 17 March 2010 13:50 Go to previous messageGo to next message
Levelx  is currently offline Levelx
Messages: 358
Registered: April 2009
Location: Germany
Faithful Member
It's important to write "groups" instead of "Groups".

Did you?

The example I posted did work in my project!
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95641 is a reply to message #92047 ] Wed, 17 March 2010 17:10 Go to previous messageGo to next message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
I've tried both, none did work
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95647 is a reply to message #92047 ] Wed, 17 March 2010 18:20 Go to previous messageGo to next message
Levelx  is currently offline Levelx
Messages: 358
Registered: April 2009
Location: Germany
Faithful Member
Please post the last test.yml you used and the exact error you get!
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95670 is a reply to message #95625 ] Thu, 18 March 2010 08:53 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Levelx wrote on Wed, 17 March 2010 13:50

It's important to write "groups" instead of "Groups".

Did you?

The example I posted did work in my project!


Show your global (project) schema.yml
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95930 is a reply to message #95670 ] Mon, 22 March 2010 10:06 Go to previous messageGo to next message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
Here is the .yml I've tried (my schema.yml does not include anything about sfGuardUser, I let the plugin define averything)

sfGuardPermission:
  pEcoles:
    name: ecoles
  pBillets:
    name: billets
  pImportEcoles:
    name: import_ecoles
 
sfGuardGroup:
  gGroupeScolaire:
    name: groupe_scolaire
 
sfGuardGroupPermission:
  gp1:
    SfGuardGroup:      gGroupeScolaire
    SfGuardPermission: pEcoles
  gp2:
    SfGuardGroup:      gGroupeScolaire
    SfGuardPermission: pBillets
  gp3:
    SfGuardGroup:      gGroupeScolaire
    SfGuardPermission: pImportEcoles

sfGuardUser:
  toto:
    username: toto
    password: t0t0
  Titi:
    username: titi
    password: t1t1
  Tata:
    username: tata
    password: t4t4
    groups: [gGroupeScolaire]


And this the error I get:
Unknown record property / related component "groups" on sfGuardUser


If it can help, using symfony doctrine:build --all --and-load does not cause any problem (but the relations tables need need to begin with "sf" and not "Sf" to work)

[Updated on: Mon, 22 March 2010 10:24]

Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95963 is a reply to message #92047 ] Mon, 22 March 2010 14:43 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
What if your just remove "groups: [gGroupeScolaire]" does it work?
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95980 is a reply to message #95963 ] Mon, 22 March 2010 16:43 Go to previous messageGo to next message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
In fact....no...it throws an error about sfguardgroup...And it worked last week, using the uppercase trick on sfGuardGroup.

I think, I'll do it another way as symfony:doctrine-build --all --and-load works, but I would like to understand why this does work and why symfony doctrine:data-load doesn't (and it would be usefull to have it work)
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #95983 is a reply to message #92047 ] Mon, 22 March 2010 16:54 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Oh, build all and load works? I don't know that it works for you..

I think can be because of symfony doctrine:data-load doesn't delete old fixtures, right?

So if you don't delete old fixtures by yourself, then group gGroupeScolaire: name: groupe_scolaire doesn't create a new row, because it already exist and then you can't use gGroupeScolaire when creating user.

What do you think about that?
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96059 is a reply to message #92047 ] Tue, 23 March 2010 17:39 Go to previous messageGo to next message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
Ok, a night of rest, and things go better. At least , I know why I had the last error: I had a .yml in a subdirectory.

I moved it and I retried my tests.

Here is the schema.yml from sfDoctrineGuardPlugin:
sfGuardGroup:
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    name:
      type: string(255)
      unique: true
    description: string(1000)
  relations:
    users:
      class: sfGuardUser
      refClass: sfGuardUserGroup
      local: group_id
      foreign: user_id
      foreignAlias: Groups
    permissions:
      class: sfGuardPermission
      local: group_id
      foreign: permission_id
      refClass: sfGuardGroupPermission
      foreignAlias: Groups

sfGuardPermission:
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    name:
      type: string(255)
      unique: true
    description: string(1000)

sfGuardGroupPermission:
  options:
    symfony:
      form:   false
      filter: false
  actAs: [Timestampable]
  columns:
    group_id:
      type: integer(4)
      primary: true
    permission_id:
      type: integer(4)
      primary: true
  relations:
    sfGuardGroup:
      local: group_id
      onDelete: CASCADE
    sfGuardPermission:
      local: permission_id
      onDelete: CASCADE

sfGuardUser:
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    username:
      type: string(128)
      notnull: true
      unique: true
    algorithm:
      type: string(128)
      default: sha1
      notnull: true
    salt: string(128)
    password: string(128)
    is_active:
      type: boolean
      default: 1
    is_super_admin:
      type: boolean
      default: false
    last_login:
      type: timestamp
  indexes:
    is_active_idx:
      fields: [is_active]
  relations:
    groups:
      class: sfGuardGroup
      local: user_id
      foreign: group_id
      refClass: sfGuardUserGroup
      foreignAlias: Users
    permissions:
      class: sfGuardPermission
      local: user_id
      foreign: permission_id
      refClass: sfGuardUserPermission
      foreignAlias: Users

sfGuardUserPermission:
  options:
    symfony:
      form:   false
      filter: false
  actAs: [Timestampable]
  columns:
    user_id:
      type: integer(4)
      primary: true
    permission_id:
      type: integer(4)
      primary: true
  relations:
    sfGuardUser:
      local: user_id
      onDelete: CASCADE
    sfGuardPermission:
      local: permission_id
      onDelete: CASCADE

sfGuardUserGroup:
  options:
    symfony:
      form:   false
      filter: false
  actAs: [Timestampable]
  columns:
    user_id:
      type: integer(4)
      primary: true
    group_id:
      type: integer(4)
      primary: true
  relations:
    sfGuardUser:
      local: user_id
      onDelete: CASCADE
    sfGuardGroup:
      local: group_id
      onDelete: CASCADE

sfGuardRememberKey:
  options:
    symfony:
      form:   false
      filter: false
  actAs: [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    user_id:
      type: integer(4)
    remember_key: string(32)
    ip_address:
      type: string(50)
      primary: true
  relations:
    sfGuardUser:
      local: user_id
      foreignAlias: RememberKeys
      foreignType: one
      onDelete: CASCADE


Here is my test file:
sfGuardPermission:
  pEcoles:
    name: ecoles
  pBillets:
    name: billets
  pImportEcoles:
    name: import_ecoles
 
sfGuardGroup:
  gGroupeScolaire:
    name: groupe_scolaire
 
sfGuardUser:
  toto:
    username: toto
    password: t0t0
  Titi:
    username: titi
    password: t1t1
  Tata:
    username: tata
    password: t4t4
    Groups: [ gGroupeScolaire ]
    
SfGuardGroupPermission:
  gp1:
    SfGuardGroup:      gGroupeScolaire
    SfGuardPermission: pEcoles
  gp2:
    SfGuardGroup:      gGroupeScolaire
    SfGuardPermission: pBillets
  gp3:
    SfGuardGroup:      gGroupeScolaire
    SfGuardPermission: pImportEcoles

It gave me the error
Unknown record property / related component "groups" on "sfGuardUser"

I tried with "groups" instead of "Groups", same result.
So I remove the "groups" line and added this at the end of the file:
SfGuardUserGroup:
  ug1:
    SfGuardGroup: gGroupeScolaire
    sfGuardUser:  toto

which threw this error:
Unknown record property / related component "sfguarduser" on "sfGuardUserGroup"

And if I use sfGuardUser instead of SfGuardUser in the last line, the error becomes:
Unknown record property / related component "sf_guard_user" on "sfGuardUserGroup"


And it looks like doctrine:data-load truncates the tables.

[Updated on: Tue, 23 March 2010 17:39]

Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96062 is a reply to message #92047 ] Tue, 23 March 2010 18:16 Go to previous messageGo to next message
Levelx  is currently offline Levelx
Messages: 358
Registered: April 2009
Location: Germany
Faithful Member
Please check in your BasesfGuardUser.class.php file, if your setUp()method includes:

        $this->hasMany('sfGuardGroup as groups', array(
             'refClass' => 'sfGuardUserGroup',
             'local' => 'user_id',
             'foreign' => 'group_id'));


or if there is something other than "as groups" written!

And you haven't redefined sfGuardUser in your schema.yml?
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96090 is a reply to message #92047 ] Wed, 24 March 2010 07:56 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Did you change something in the sfDoctrineGuardPlugin? Or you just install it and want to create a fixtures?

If so, what did you change?
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96102 is a reply to message #96090 ] Wed, 24 March 2010 11:48 Go to previous messageGo to next message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
Here is the setUp() function from BaseSfGuardUser.class.php in /lib/model/doctrin/base

    public function setUp()
    {
        parent::setUp();
        $this->hasMany('SfGuardRememberKey', array(
             'local' => 'id',
             'foreign' => 'user_id'));

        $this->hasMany('SfGuardUserGroup', array(
             'local' => 'id',
             'foreign' => 'user_id'));

        $this->hasMany('SfGuardUserPermission', array(
             'local' => 'id',
             'foreign' => 'user_id'));
    }


I haven't done any modification to the plugin or redefined tables in the schema.yml in my project.
My goal is to be able to reload my fixtures at will without having to dump the database each time by using doctrine:build --all --and-load
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96103 is a reply to message #92047 ] Wed, 24 March 2010 11:59 Go to previous messageGo to next message
Levelx  is currently offline Levelx
Messages: 358
Registered: April 2009
Location: Germany
Faithful Member
Seems to me like your posted schema.yml and your generated baseClasses are not belonging together.

The base class is missing the relations to groups and permissions that are shown in your posted schema.

relations:
    groups:
      class: sfGuardGroup
      local: user_id
      foreign: group_id
      refClass: sfGuardUserGroup
      foreignAlias: Users
    permissions:
      class: sfGuardPermission
      local: user_id
      foreign: permission_id
      refClass: sfGuardUserPermission
      foreignAlias: Users


Can you check the file again after executing:
symfony doctrine:build --all-classes
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96106 is a reply to message #96102 ] Wed, 24 March 2010 12:20 Go to previous messageGo to next message
tomor  is currently offline tomor
Messages: 110
Registered: December 2009
Senior Member
Tanatiel wrote on Wed, 24 March 2010 11:48

Here is the setUp() function from BaseSfGuardUser.class.php in /lib/model/doctrin/base

.......

Is your path of the BaseSfGuardUser.class.php

/lib/model/doctrin/base
or
/lib/model/doctrine/sfDoctrineGuardPlugin/base
?

[Updated on: Wed, 24 March 2010 12:53]

Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96108 is a reply to message #92047 ] Wed, 24 March 2010 12:38 Go to previous messageGo to next message
Levelx  is currently offline Levelx
Messages: 358
Registered: April 2009
Location: Germany
Faithful Member
only

lib/model/doctrine/sfDoctrineGuardPlugin/base

if you don't add the sfGuardUser to your own schema.yml
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96133 is a reply to message #92047 ] Wed, 24 March 2010 16:13 Go to previous messageGo to next message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
I'll try a rebuild and I checked my directories and...surprise!

BaseSfGuardUser exists in both /lib/model/doctrine/base and /lib/model/doctrine/sfDoctrineGuardPlugin/base !

My schema.yml from /config/doctrine does not redefine anything from the plugin, it only contains the definitions of my own tables.

I think I will clear /lib/model/doctrine/base by the hand and try a rebuild, things should be better after...if the build task does not rebuild BaseSfGuardUser in two directories!

Here is the content of my /lib/model/doctrine/sfDoctrineGuardPlugin/base/BaseSfGuardUs er.class.php
public function setUp()
    {
        parent::setUp();
        $this->hasMany('sfGuardGroup as groups', array(
             'refClass' => 'sfGuardUserGroup',
             'local' => 'user_id',
             'foreign' => 'group_id'));

        $this->hasMany('sfGuardPermission as permissions', array(
             'refClass' => 'sfGuardUserPermission',
             'local' => 'user_id',
             'foreign' => 'permission_id'));

        $this->hasMany('sfGuardUserPermission', array(
             'local' => 'id',
             'foreign' => 'user_id'));

        $this->hasMany('sfGuardUserGroup', array(
             'local' => 'id',
             'foreign' => 'user_id'));

        $this->hasOne('sfGuardRememberKey as RememberKeys', array(
             'local' => 'id',
             'foreign' => 'user_id'));

        $timestampable0 = new Doctrine_Template_Timestampable();
        $this->actAs($timestampable0);
    }

It is far more coherent.

BRB!
Re: [SOLVED] sfDoctrineGuardPlugin - Error during data-load [message #96134 is a reply to message #96133 ] Wed, 24 March 2010 16:19 Go to previous message
Tanatiel  is currently offline Tanatiel
Messages: 9
Registered: March 2010
Location: Nantes (France)
Junior Member
I've tried a doctrine:build --all-classes task and after I found BaseSfUserGuard in both directories as before. Here is my schema.yml from config/doctrine:
Mairie:
  columns:
    nom: { type: string(50), notnull: true, unique: true }
    email: { type: string(50), notnull: true }
    
Ecole:
  actAs: { Timestampable: ~ }
  columns:
    code: { type: string(20), notnull: true, unique: true, primary: true}
    password: { type: string(20), notnull: true}
    nom: { type: string(30), notnull: true}
    type_etab: { type: enum, values: [E,P,M] }
    mairie_id: { type: integer, notnull: true }
    email: { type: string(50), notnull: true }
    adresse1: { type: string(35), notnull: true }
    adresse2: { type: string(35) }
    cp: { type: int(5), notnull: true }
    ville: { type: string(100), notnull: true }
    is_active: { type: boolean, default: 1 }
    nb_trials: { type: integer, default: 0 }
  indexes:
    is_active_idx:
      fields: [is_active]
  relations:
    Mairie: { local: mairie_id, foreign: id, foreignAlias: Ecoles }

MotifDepl:
  columns:
    libelle: { type: string(50), notnull: true }

Billet:
  actAs:
    Timestampable:
      updated:
        disabled: true
  columns:
    numero: { type: integer, primary: true, autoincrement: true } 
    etab_code: { type: string(20), notnull: true }
    resp_civ: { type: string(4), notnull: true }
    resp_nom: { type: string(100), notnull: true }
    resp_prenom: { type: string(50), notnull: true }
    nb_eleves: { type: tinyint(2), notnull: true }
    nb_accomp: { type: tinyint(2), notnull: true }
    date_depl: { type: timestamp, notnull: true }
    trajet: { type: tinyint(1), notnull: true }
    motifdepl_id: { type: integer, notnull: true }
  relations:
    Ecole: { local: etab_code, foreign: code, foreignAlias: Billets }
    MotifDepl: { local: motifdepl_id, foreign: id, foreignAlias: Billets }

ExportMairie:
  actAs:
    Timestampable:
      updated:
        disabled: true
  columns:
    mairie_id: { type: integer, notnull: true }
    periode_deb: { type: timestamp, notnull: true }
    periode_fin: { type: timestamp, notnull: true }
    fichierXLS: { type: string(150), notnull: true }
    fichierPDF: { type: string(150), notnull: true }
  relations:
    Mairie: { local: mairie_id, foreign: id, foreignAlias: Exports }

As you can see, there is no redifinition of sfGuardUser or any other table from the plugin...so why happens with the build task?
[edit]
Ok, I cleaned /lib/model/doctrine/base by the hand and the sfGuard classes did not come back after a build. I'll try my data-load now. I'll keep in touch, pfiuuuuu
[edit 2]
Ok, I tried the data-load and it worked well with "sf" prefix.
I'll make some trials with doctrine:build --all --and-load to be sure.

Thanks a lot for your help!

[Updated on: Wed, 24 March 2010 16:35]

Previous Topic:Simple One-to-many with doctrine
Next Topic:doctrine:build-schema doesn't generate foreign keys
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software