Open parijke opened 1 year ago
Can you include the traceback for that error?
Like this @zerocrates ?
Details:
Doctrine\ORM\ORMInvalidArgumentException: A new entity was found through the relationship 'Omeka\Entity\FulltextSearch#owner' that was not configured to cascade persist operations for entity: Omeka\Entity\User@344. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'Omeka\Entity\User#__toString()' to get a clue. in /app/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:97
Stack trace:
#0 /app/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(3520): Doctrine\ORM\ORMInvalidArgumentException::newEntitiesFoundThroughRelationships(Array)
#1 /app/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(390): Doctrine\ORM\UnitOfWork->assertThatThereAreNoUnintentionallyNonPersistedAssociations()
#2 /app/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(392): Doctrine\ORM\UnitOfWork->commit(Object(Omeka\Entity\FulltextSearch))
#3 /app/application/src/Stdlib/FulltextSearch.php(43): Doctrine\ORM\EntityManager->flush(Object(Omeka\Entity\FulltextSearch))
#4 /app/application/Module.php(574): Omeka\Stdlib\FulltextSearch->save(Object(Omeka\Entity\Item), Object(Omeka\Api\Adapter\ItemAdapter))
#5 /app/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Omeka\Module->saveFulltext(Object(Laminas\EventManager\Event))
#6 /app/vendor/laminas/laminas-eventmanager/src/EventManager.php(171): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\EventManager\Event))
#7 /app/application/src/Api/Manager.php(323): Laminas\EventManager\EventManager->triggerEvent(Object(Laminas\EventManager\Event))
#8 /app/application/src/Api/Manager.php(269): Omeka\Api\Manager->finalize(Object(Omeka\Api\Adapter\ItemAdapter), Object(Omeka\Api\Request), Object(Omeka\Api\Response))
#9 /app/application/src/Api/Manager.php(136): Omeka\Api\Manager->execute(Object(Omeka\Api\Request))
#10 /app/application/src/Mvc/Controller/Plugin/Api.php(152): Omeka\Api\Manager->update('items', '18', Array, Array, Array)
#11 /app/application/src/Controller/Admin/ItemController.php(254): Omeka\Mvc\Controller\Plugin\Api->update('items', '18', Array, Array)
#12 /app/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(71): Omeka\Controller\Admin\ItemController->editAction()
#13 /app/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Laminas\Mvc\Controller\AbstractActionController->onDispatch(Object(Laminas\Mvc\MvcEvent))
#14 /app/vendor/laminas/laminas-eventmanager/src/EventManager.php(179): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure))
#15 /app/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(97): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent))
#16 /app/vendor/laminas/laminas-mvc/src/DispatchListener.php(132): Laminas\Mvc\Controller\AbstractController->dispatch(Object(Laminas\Http\PhpEnvironment\Request), Object(Laminas\Http\PhpEnvironment\Response))
#17 /app/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Laminas\Mvc\DispatchListener->onDispatch(Object(Laminas\Mvc\MvcEvent))
#18 /app/vendor/laminas/laminas-eventmanager/src/EventManager.php(179): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure))
#19 /app/vendor/laminas/laminas-mvc/src/Application.php(325): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent))
#20 /app/index.php(21): Laminas\Mvc\Application->run()
#21 {main}
Yes, like that.
Ultimately the problem here, I think, is going to be the call to clear()
in the Synchronous job adapter... it's quite unlikely to work properly if you are doing more work after the job is over.
Are you looking to do code that's like this specifically, in that you'd explicitly fire off Synchronous jobs like in your test code? There's not much point to use the job system at all if you're forcing it to run synchronous.
The reason it was synchronous was for debugging purposes. It runs fine in background mode. Not sure that this is a bug or an expected result then.
How to replicate:
Create a listener for api.update.pre
Then in dispatchjobs, dispatch two times
TestJob is just a job with an empty perform()
Error
Listening for the
api.update.post
event throws same error, even with one job