Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORMInvalidArgumentException after installation #1704

Closed
phaidon opened this issue May 25, 2014 · 18 comments
Closed

ORMInvalidArgumentException after installation #1704

phaidon opened this issue May 25, 2014 · 18 comments
Milestone

Comments

@phaidon
Copy link
Contributor

phaidon commented May 25, 2014

I got the following error after a fresh installation

ORMInvalidArgumentException: EntityManager#persist() expects parameter 1 to be an entity object, NULL given.
in Zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php line 169

@craigh
Copy link
Member

craigh commented May 25, 2014

if possible please provide the full trace.

Also can you say exactly when this happens?

@craigh craigh added this to the 1.4.0 milestone May 26, 2014
@phaidon
Copy link
Contributor Author

phaidon commented May 29, 2014

    1.  in src/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php line 169
    2.  at ORMInvalidArgumentException::invalidObject('EntityManager#persist()', null) in src/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 619
    3.  at EntityManager->persist(null) in src/vendor/gedmo/doctrine-extensions/lib/Gedmo/Blameable/BlameableListener.php line 86
    4.  at BlameableListener->updateField(object(CategoryEntity), object(ORM), object(ClassMetadata), 'lu_uid') in src/vendor/gedmo/doctrine-extensions/lib/Gedmo/Timestampable/TimestampableListener.php line 148
    5.  at TimestampableListener->prePersist(object(LifecycleEventArgs)) in src/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 61
    6.  at ContainerAwareEventManager->dispatchEvent('prePersist', object(LifecycleEventArgs)) in src/vendor/doctrine/orm/lib/Doctrine/ORM/Event/ListenersInvoker.php line 117
    7.  at ListenersInvoker->invoke(object(ClassMetadata), 'prePersist', object(CategoryEntity), object(LifecycleEventArgs), '4') in src/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 845
    8.  at UnitOfWork->persistNew(object(ClassMetadata), object(CategoryEntity)) in src/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 1626
    9.  at UnitOfWork->doPersist(object(CategoryEntity), array('000000004680b2160000000105cb4455' => object(CategoryEntity))) in src/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 1582
    10. at UnitOfWork->persist(object(CategoryEntity)) in src/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 624
    11. at EntityManager->persist(object(CategoryEntity)) in src/system/Zikula/Module/CategoriesModule/CategoriesModuleInstaller.php line 696
    12. at CategoriesModuleInstaller->insertData_10() in src/system/Zikula/Module/CategoriesModule/CategoriesModuleInstaller.php line 53
    13. at CategoriesModuleInstaller->install() in src/install/lib.php line 419
    14. at installmodules('en') in src/install/lib.php line 247
    15. at install(object(Zikula_Core), object(Zikula_Request_Http)) in src/install.php line 24

It happens during the install process.

It seems to be that the problem is in the categories module.

@Guite
Copy link
Member

Guite commented May 29, 2014

It happens when the system tries to insert initial categories data.

Here is the stack trace:


ORMInvalidArgumentException: EntityManager#persist() expects parameter 1 to be an entity object, NULL given.
in zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php line 169
at ORMInvalidArgumentException::invalidObject('EntityManager#persist()', null) in zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 619
at EntityManager->persist(null) in zikula/src/vendor/gedmo/doctrine-extensions/lib/Gedmo/Blameable/BlameableListener.php line 86
at BlameableListener->updateField(object(CategoryEntity), object(ORM), object(ClassMetadata), 'lu_uid') in zikula/src/vendor/gedmo/doctrine-extensions/lib/Gedmo/Timestampable/TimestampableListener.php line 148
at TimestampableListener->prePersist(object(LifecycleEventArgs)) in zikula/src/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php line 61
at ContainerAwareEventManager->dispatchEvent('prePersist', object(LifecycleEventArgs)) in zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/Event/ListenersInvoker.php line 117
at ListenersInvoker->invoke(object(ClassMetadata), 'prePersist', object(CategoryEntity), object(LifecycleEventArgs), '4') in zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 845
at UnitOfWork->persistNew(object(ClassMetadata), object(CategoryEntity)) in zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 1626
at UnitOfWork->doPersist(object(CategoryEntity), array('000000006a1b9da700007f3266c417e0' => object(CategoryEntity))) in zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 1582
at UnitOfWork->persist(object(CategoryEntity)) in zikula/src/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php line 624
at EntityManager->persist(object(CategoryEntity)) in zikula/src/system/Zikula/Module/CategoriesModule/CategoriesModuleInstaller.php line 696
at CategoriesModuleInstaller->insertData_10() in zikula/src/system/Zikula/Module/CategoriesModule/CategoriesModuleInstaller.php line 53
at CategoriesModuleInstaller->install() in zikula/src/install/lib.php line 419
at installmodules('en') in zikula/src/install/lib.php line 247
at install(object(Zikula_Core), object(Zikula_Request_Http)) in zikula/src/install.php line 24

@phaidon
Copy link
Contributor Author

phaidon commented May 29, 2014

I tried to find the problem, but without success. Would be nice if someone could solve this problem, because I this a blocker for my activities..

@craigh
Copy link
Member

craigh commented May 29, 2014

I'll take a look as soon as I can.

@phaidon
Copy link
Contributor Author

phaidon commented May 29, 2014

Here what I already found out:

The error happens in :

1 .https://github.com/zikula/core/blob/1.4/src/system/Zikula/Module/CategoriesModule/CategoriesModuleInstaller.php#L53

and in
.https://github.com/zikula/core/blob/1.4/src/system/Zikula/Module/CategoriesModule/CategoriesModuleInstaller.php#L55

// Set autonumber to 10000 (for DB's that support autonumber fields)
$cat = new CategoryEntity;
$cat['id'] = 9999;
$this->entityManager->persist($cat);
$this->entityManager->flush();
$this->entityManager->remove($cat);
$this->entityManager->flush();

@craigh
Copy link
Member

craigh commented May 29, 2014

the trace indicates it is trying to process the $this->insertData_10(); call (in line 53) and fails when it tries to persist the data there, not the code you show above.

@craigh
Copy link
Member

craigh commented May 29, 2014

there are several flaws with the installation of the category structure. I will see what I can do. I think I have found the first major problem which is causing the error though

@craigh
Copy link
Member

craigh commented May 29, 2014

This is a problem with the Gedmo/Blameable extension. It is not firing correctly on the installation. probably because nobody is logged in yet... not sure why this used to work and now does not. Maybe because I switched it from the old StandardFields to Blameable. @cmfcmf do you have any ideas for a fix?

@craigh
Copy link
Member

craigh commented May 30, 2014

@Guite can you look into this also?

@Guite
Copy link
Member

Guite commented May 30, 2014

What was the reason for switching from StandardFields to Blameable?

@craigh
Copy link
Member

craigh commented May 30, 2014

2 reasons: first, I couldn't get standard fields to work. second, using third-party code means not having to maintain our code.

but I'm not sure that even switching back would be the solution here. The problem is that the CategoryEntity requires a UserEntity in two places (https://github.com/zikula/core/blob/1.4/src/system/Zikula/Module/CategoriesModule/Entity/CategoryEntity.php#L151-L167) On installation, the user entity isn't available so the install fails.

I suppose one easy solution is to remove those two properties.

@Guite
Copy link
Member

Guite commented May 30, 2014

I guess the difference is that Blameable actually tries to join a user. StandardFields just uses UserUtil::getVar('uid') (iirc) which works for guests, too.

@cmfcmf
Copy link
Contributor

cmfcmf commented May 30, 2014

src/lib/Zikula/Bundle/CoreBundle/EventListener/BlameListener.php::onPostInit should be checked I guess. This looks like the place where it's failing to set a user.

@craigh
Copy link
Member

craigh commented May 30, 2014

yes, I already tried a few ideas in the listener and couldn't create a user, so I am still looking for ideas.

@cmfcmf cmfcmf mentioned this issue Jun 4, 2014
9 tasks
@Guite
Copy link
Member

Guite commented Jun 4, 2014

Maybe doctrine-extensions/DoctrineExtensions#1048 is related here?

@craigh
Copy link
Member

craigh commented Jun 4, 2014

@Guite that seems likely - how do we fix?

@craigh craigh closed this as completed in d5ef2b8 Jun 5, 2014
ghost pushed a commit that referenced this issue Jun 5, 2014
accommodate blameable user value when installing. fixes #1704
@luishdez
Copy link

I think the doctrine extension problem is related to this. doctrine-extensions/DoctrineExtensions#1191
someone add some code to the blamable extension that remove the possibility to set null values to those properties. That caused some bc problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants