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 » plugins » General plug-ins » [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation?
[sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #21387] Sat, 10 February 2007 23:54 Go to next message
qube  is currently offline qube
Messages: 88
Registered: August 2006
Location: Czech republic
Member
Hi,

I experienced following problem after installing sfGuardPlugin

...
[propel-om] Processing: generated-schema.xml
[propel-om] Processing: generated-sfGuardPlugin-schema.xml
Execution of target "om-template" failed for the following reason: 
C:\php51\PEAR\symfony\vendor\propel-generator\build-propel.xml:436:1: Duplicate table found: propel.


update: This problem is caused by building your schema from database (propel-build-schema) command after sfGuardPlugin installation. Propel-build-schema command generates schema.yml with sfGuard tables and therefor tables are defined twice. Once in /config/schema.yml and once in /plugins/sfGuardPlugin/config/schema.yml.

If you need to use propel-build-schema, you can try following solutions (none is perfect):

1) Most clean solution would be, to delete table definitions from generated schema.yml after running propel-build-schema. But this is not very convenient.

2) Edit propel.ini and set
propel.packageObjectModel = false
I don't know what exactly this switch do, but it solves many problems, when I look around the forum.
(found here: http://www.symfony-project.com/forum/index.php/m/21319/?srch =propel.packageObjectModel#msg_21319).

3) Rename database name in one of the schemas:
<database name="propel2" defaultIdMethod="native" package="plugins.sfGuardPlugin.lib.model">

If you do this, you must update database.yml and set connection parameters for your second database name. Maybe there are other consequences I'm not aware of.

This works regardless on settings of propel.packageObjectModel in propel.ini.

4) Delete /plugins/sfGuardPlugin/config/schema.yml, /plugins/sfGuardPlugin/config/schema.xml. By doing this, there is only one definition of tables and thus no problem for Propel.
(as advised by blizzard-media here: http://www.symfony-project.com/forum/index.php/t/4205/)


All these solutions (except 1)) have disadvantage, that sfGuard classes are generated into your /lib/model directory. But despite of this, model classes from /plugins/sfGuardPlugin/lib/model are used anyway.

Note: When experimenting with various settings, clear you cache and cookies, otherwise you can get following error:
Fatal error: Cannot redeclare class sfguardusermapbuilder in ...\plugins\sfGuardPlugin\lib\model\map\sfGuardUserMapBuilder.php on line 5



Is there some correct solution how to use propel-build-schema wit installed plugin, which has own db tables?

[Updated on: Sun, 11 February 2007 16:12]

Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #21426 is a reply to message #21387 ] Mon, 12 February 2007 09:54 Go to previous messageGo to next message
francois  is currently offline francois
Messages: 1636
Registered: October 2005
Faithful Member
I think this problem is worth a ticket. Could you open it?
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #21433 is a reply to message #21426 ] Mon, 12 February 2007 11:01 Go to previous messageGo to next message
qube  is currently offline qube
Messages: 88
Registered: August 2006
Location: Czech republic
Member
opened ticket http://www.symfony-project.com/trac/ticket/1447
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #25730 is a reply to message #21387 ] Mon, 16 April 2007 09:22 Go to previous messageGo to next message
Junni  is currently offline Junni
Messages: 90
Registered: January 2007
Location: Belgium
Member
Fatal error: Cannot redeclare class sfguardusermapbuilder in ...\plugins\sfGuardPlugin\lib\model\map\sfGuardUserMapBuilder.php on line 5


I'm working on an existing project (not made by me) and I'm getting this error when I try to view the 'User Management' page. I did clear my cookies and temp files. sfGuard is upgraded to version 1.1.7.


CryptoNet | X-Power
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #27192 is a reply to message #25730 ] Mon, 14 May 2007 16:11 Go to previous messageGo to next message
kevinold  is currently offline kevinold
Messages: 20
Registered: March 2007
Junior Member
I too am seeing this error on a new project I've created. I'm not sure if sfGuardPlugin is ready for prime time just yet as this kind of functionality has been a major show stopper in my "quick development" of a project.
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #27710 is a reply to message #25730 ] Mon, 21 May 2007 00:28 Go to previous messageGo to next message
qube  is currently offline qube
Messages: 88
Registered: August 2006
Location: Czech republic
Member
Junni, kevinold: Try clearing your cache, it should help.
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #27785 is a reply to message #27710 ] Mon, 21 May 2007 20:12 Go to previous messageGo to next message
kevinold  is currently offline kevinold
Messages: 20
Registered: March 2007
Junior Member
Ok, clearing my cache this time worked. I'd done it a million times before with no luck. I think also deleting the sql files in 'data/sql' might be helpful too.
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #27821 is a reply to message #21387 ] Tue, 22 May 2007 10:23 Go to previous messageGo to next message
Jackovson  is currently offline Jackovson
Messages: 83
Registered: March 2007
Member
Sad

I have a similar problem (or a part of it), and i cant resolve it.

I am using Symfony 1.0.1 and sfGuardPlugin 1.1.7.

I tried quite all solutions above... but i am having the error
Fatal error: Cannot redeclare class sfguardusermapbuilder in .../plugins/sfGuardPlugin/lib/model/map/sfGuardUserMapBuilder.php on line 5

When trying to access /frontend_dev.php/sfGuardUser

I have cleared the cache million times, and cleared cookies (???) too Crying or Very Sad

This problem is very... problematic ( Shocked Rolling Eyes ) for my project, and i cant continue to work without resolving it Sad

I will try to re-install the plugin completely...
A crazy thing : i create a new Symphony project, install the plugin, create a little schema.xml in /my_project/config, i run propel-build-model (ok), i create an app and activate sfGuard modules, and i can access to http://.../frontend_dev.php/sfGuarduser

I dont know what to do...

please, help Rolling Eyes


[Edit]
Some precisions :
I uninstalled the plugin (symfony plugin-uninstall symfony/sfGuardPlugin), i cleared files (/project/plugins/sfGuardPlugin). Here my project is ok : i generate model (symfony propel-build-model), and my modules are ok.
I install the plugin (via symfony plugin-install ....), i rebuild the model (seems to be ok : first my tables in my /config/schema.xml, then tables of the plugin), and when i try to access http://my_project/frontend_dev.php/sfGuardUser, i have the error Fatal error: Cannot redeclare class sfguardusermapbuilder in .../plugins/sfGuardPlugin/lib/model/map/sfGuardUserMapBuilde r.php on line 5 ... Sad

[Updated on: Tue, 22 May 2007 10:50]

Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #27875 is a reply to message #27821 ] Tue, 22 May 2007 23:50 Go to previous messageGo to next message
qube  is currently offline qube
Messages: 88
Registered: August 2006
Location: Czech republic
Member
Try checking your model directory (lib/model/), if there aren't sfGuardPlugin model classes. They should be present only once in plugins/sfGuardPlugin/lib/model/.

This can happen, if you build model from schama.xml, which was generated from db, where sfGuardPlugin tables were already installed.
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #27876 is a reply to message #27875 ] Wed, 23 May 2007 00:12 Go to previous messageGo to next message
Jackovson  is currently offline Jackovson
Messages: 83
Registered: March 2007
Member
Youre right, i found it this afternoon.

I was looking for diffrence between my two projects : the one which was ok and the other one.
By comparing the two folders tree i found some class in /lib/model/map... I cleared them, cleared the cache, and it was ok Razz

"This can happen"
Is it a bug ?

Thank you for help. Smile

[Updated on: Wed, 23 May 2007 00:12]

Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #27978 is a reply to message #27876 ] Wed, 23 May 2007 18:32 Go to previous messageGo to next message
qube  is currently offline qube
Messages: 88
Registered: August 2006
Location: Czech republic
Member
You are welcome.

Yes, it is a bug I described in the first post (simply: no plugin with db schema will work correctly if you will use propel-build-schema).

Ticket is opened for it already.
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #28024 is a reply to message #27978 ] Thu, 24 May 2007 09:53 Go to previous messageGo to next message
Jackovson  is currently offline Jackovson
Messages: 83
Registered: March 2007
Member
qube wrote on Wed, 23 May 2007 18:32

Ticket is opened for it already.

Oh ok !

Maybe for the next release it will be closed Very Happy

Most important is to know the origin of the problem, and most most most most important : to know how to repair it (because an error like that can completely break a project Confused )


Thanks again,
Bye.
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #48599 is a reply to message #21387 ] Wed, 26 March 2008 19:56 Go to previous messageGo to next message
bstoppel  is currently offline bstoppel
Messages: 55
Registered: February 2006
Location: Lawrence, KS
Member
BTW - This is still an issue with Symfony 1.1.
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #49594 is a reply to message #21387 ] Wed, 09 April 2008 19:49 Go to previous messageGo to next message
oloynet  is currently offline oloynet
Messages: 1
Registered: February 2008
Junior Member
I wrote this snippet to avoid the problem of sfGuard tables in your main schema
http://www.symfony-project.org/snippets/snippet/298

Olivier

Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #50150 is a reply to message #21387 ] Wed, 16 April 2008 22:33 Go to previous messageGo to next message
naholyr  is currently offline naholyr
Messages: 223
Registered: June 2007
Faithful Member
Maybe we're simply not supposed to call "propel-build-schema" as soon as we already have a schema (which is the case when we installed a plugin with a schema) ?
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #62130 is a reply to message #21387 ] Tue, 30 September 2008 13:16 Go to previous messageGo to next message
mariusbutuc  is currently offline mariusbutuc
Messages: 6
Registered: September 2008
Location: Iasi, RO
Junior Member
qube wrote on Sat, 10 February 2007 23:54

1) Most clean solution would be, to delete table definitions from generated schema.yml after running propel-build-schema. But this is not very convenient.


This worked for me! Thanks!
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #63308 is a reply to message #21387 ] Fri, 17 October 2008 02:43 Go to previous messageGo to next message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
I usually do this, so, i hope it helps!! It's always worked for me and is quite easy to script as well.

Setup #1) In config/settings.yml - add an extra database alias

all:
  propel:
    class:          sfPropelDatabase
    param:
      dsn:          mysql://root@localhost/mydb
  sfguard:
    class:          sfPropelDatabase
    param:
      dsn:          mysql://root@localhost/mydb


Setup #2) In plugins/sfGuardPlugin/config/schema.yml - change the name of database connection alias,

propel:  <== replace this line
  _attributes:      { package: plugins.sfGuardPlugin.lib.model }


to,
sfguard: <== with this line
  _attributes:      { package: plugins.sfGuardPlugin.lib.model }


Build
I usually wrap the Build Steps into a shell script or batch file.

Build #1) Execute the following command to build the schema,
symfony propel-build-schema


Build #2) Execute the following command to build the model,
symfony propel-build-model


Build #3) Execute one of the following commands to delete the garbage sfGuard files. (The files all appear in /lib with uppercase "Sf" instead of lowercase "sf", so, they're easy to find).
# unix and mac
find ./lib -name *SfGuard* -type f -exec rm -f {} \;
# windows
del /F /Q /S .\lib\*SfGuard*


[Updated on: Fri, 17 October 2008 03:07]

Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #77683 is a reply to message #63308 ] Sun, 03 May 2009 12:48 Go to previous messageGo to next message
ventzy  is currently offline ventzy
Messages: 22
Registered: June 2008
Junior Member
So ugly hacks!

I am using GUI app for managing my DB, so I am always building the schema from DB, not DB from schema. I can't work without resolving this situation. I think that this is valid bug in symfony, but it seems that it is ignored. And it is not only with sfGuard plugin. I have the same problem with sfPropelVersionableBehaviorPlugin. I suppose every plugin with model will have it.

I have task "Build from db" and I am forced to do ugly hacks... so here is execute method (symfony 1.2.7):

    $this->log("");
    $this->log("------ Building schema ------");
    $c = new sfPropelBuildSchemaTask($this->dispatcher, $this->formatter);
    $c->run();

    $this->log("");
    $this->log("------ Building model ------");
    $c = new sfPropelBuildModelTask($this->dispatcher, $this->formatter);
    $c->run();    

    $this->log("");
    $this->log("------ Clearing unnecessary models ------");
    $modelDir = sfConfig::get('sf_lib_dir').'\model';
    $files = array_merge( 
      sfFinder::type('file')->name('*SfGuard*')->in($modelDir),
      sfFinder::type('file')->name('*ResourceVersion*')->in($modelDir),
      sfFinder::type('file')->name('*ResourceAttributeVersion*')->in($modelDir)
    );
    $this->getFilesystem()->remove($files);  
   
    $this->log("");
    $this->log("------ Building forms ------");
    $c = new sfPropelBuildFormsTask($this->dispatcher, $this->formatter);
    $c->run();
    
    $this->log("");
    $this->log("------ Building filters ------");
    $c = new sfPropelBuildFiltersTask($this->dispatcher, $this->formatter);
    $c->run();    
    
    $this->log("");
    $this->log("------ Clearing cache ------");
    $c = new sfCacheClearTask($this->dispatcher, $this->formatter);
    $c->run();

[Updated on: Sun, 03 May 2009 12:50]

Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #77748 is a reply to message #77683 ] Mon, 04 May 2009 19:08 Go to previous messageGo to next message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
i agree that this is a weird bug and has been a pain for me always. but, perhaps we are using symfony in a strange way.

anyway, i have another hack fix for this. basically 2 scripts, build.bat, which builds everything and then a php script that is run by build.bat.

The php script does some text replacements on the schema file and removes unwanted references that cause problems when building the model.

hope this one helps you out.

  • Attachment: symfony.zip
    (Size: 1.11KB, Downloaded 49 time(s))

Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #77773 is a reply to message #77748 ] Tue, 05 May 2009 01:09 Go to previous messageGo to next message
ventzy  is currently offline ventzy
Messages: 22
Registered: June 2008
Junior Member
Good to know that I am not alone with this Smile

As I have 3 plugins (for now) that makes trouble, I wanted more universal solution, so here is yet another fix. That should work for any plugin without manual specifing which tables to be removed from generated schema.yml. Table names that are removed are gathered from schema.yml files in the plugins.

I created two tasks - clear-schema-yml and build-from-db.

Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #77895 is a reply to message #77773 ] Thu, 07 May 2009 08:26 Go to previous messageGo to next message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
great! i'll try these out on my next symfony project and let you know how it goes.
Re: [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #78395 is a reply to message #77895 ] Thu, 14 May 2009 22:47 Go to previous message
searaig  is currently offline searaig
Messages: 43
Registered: December 2006
Location: vancouver
Member
hey, those tasks worked perfectly.

i needed them for a 1.0 project, so, here are your tasks rewritten for 1.0

i placed this file in /data/symfony/tasks for my frozen project.

cheers and thnx

Previous Topic:[New plugin]sfFilebasePlugin
Next Topic:sfAssetsLibraryPlugin 1.0 - not displaying form labels
Goto Forum:
  

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