| [sfGuard] how to correctly use propel-build-schema after sfGuardPlugin installation? [message #21387] |
Sat, 10 February 2007 23:54  |
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 #25730 is a reply to message #21387 ] |
Mon, 16 April 2007 09:22   |
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 #27821 is a reply to message #21387 ] |
Tue, 22 May 2007 10:23   |
Jackovson Messages: 83 Registered: March 2007 |
Member |
|
|
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
This problem is very... problematic ( ) for my project, and i cant continue to work without resolving it
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
[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 ...
[Updated on: Tue, 22 May 2007 10:50]
|
|
|
|
|
|
|
|
|
|
|
| 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   |
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   |
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   |
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 #78395 is a reply to message #77895 ] |
Thu, 14 May 2009 22:47  |
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
|
|
|