kayue / KayueWordpressBundle

A Symfony 2 bundle for providing WordPress repositories and authenticating users (login).
101 stars 43 forks source link

Incompatibility with doctrine fixtures #36

Closed benglass closed 10 years ago

benglass commented 10 years ago

It seems that this bundle may have a compatibility issue with doctrine fixtures and migrations in that it causes doctrine to want to modify wordpress tables whenever you generate a schema diff or when you try to load fixtures.

We like that this bundle provides a doctrine-friendly interface to retrieving and displaying blog data, but we need the blog tables to not be effected by doctrine fixtures because they are part of the wordpress application and not the main application. Doctrine fixtures wants to modify foreign keys on wordpress tables and complains that wp_blogs table doesnt exist if you arent using a multi-blog wordpress install.

Are we doing something wrong? Is there a way to solve this via configuration?

kayue commented 10 years ago

@benglass I have the same problem and sadly I don't have a solution to this problem...

benglass commented 10 years ago

@kayue Related discussion in doctrine data fixtures library

kayue commented 10 years ago

@benglass Thanks!

Beside purging, schema update is also a problem in this bundle.

benglass commented 10 years ago

Solution is to provide a separate entity manager.

The solution for schema update is to use the doctrine configuration schemafilter option to get doctrine to ignore tables starting with wp

http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html#manual-tables

doctrine:
    dbal:
        schema_filter: ~^(?!wp_)~
benglass commented 10 years ago

This issue can technically be closed but it might be nice to put this information in the documentation

kayue commented 10 years ago

Cool stuff! :+1:

Will update the doc and then I will close the issue. Thanks a lot!

kayue commented 9 years ago

@benglass In v2 the bundle uses Doctrine connection instead of Entity Manager, which solve this problem from the root.

It comes with other BC so please test it first :)

benglass commented 9 years ago

@kayue thanks for the heads up! Any way you could point me at a file that shows how it is using the connection instead of the entity manager? I browsed the beta 2.* tag and it looks like normal doctrine entities to me

kayue commented 9 years ago

@benglass We still create entity manager, but we no longer register WordpressBundle's entities to the default entity manager, we now create the entity manager from sketch, thus it won't mess up the Doctrine schema tools.

https://github.com/kayue/KayueWordpressBundle/blob/master/Wordpress/ManagerRegistry.php#L70