kayue / KayueWordpressBundle

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

Cannot persist Comment or Post entities #34

Open marcomarcomarco opened 10 years ago

marcomarcomarco commented 10 years ago

Hi,

if i try to persist a post or comment entity, i get this error from doctrine: ContextErrorException: Notice: Undefined index: 000000000895bb6c00007ff6bd269d51 in /var/www/FlywersApi/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 2860

I think that this is because i cannot synchronize the db schema, indeed, running "php app/console doctrine:schema:update" i get:

[Doctrine\DBAL\DBALException]
An exception occurred while executing 'ALTER TABLE wp_postmeta ADD CONSTRAINT FK_41C0A2764B89032C FOREIGN KEY (post_id) REFERENCES wp_posts (ID)':

SQLSTATE[HY000]: General error: 1005 Can't create table 'flywers.#sql-4a3d_13adb' (errno: 150)

How could i solve this problem? i would just need to persist a new comment

benglass commented 10 years ago

@marcomarcomarco you should disable doctrine orm auto mapping and instead create a separate entity manager for the wordpress bundle to use which only maps the wordpress bundle entities. This will prevent issues with doctrine:schema:update trying to modify wordpress tables

doctrine:
    orm:
        entity_managers:
            default:
                mappings:
                    MyNormalBundle: ~
                    AnotherBundle: ~
            wordpress:
                mappings:
                    KayueWordpressBundle: ~

kayue_wordpress:
    entity_manager: wordpress