Not configured to cascade persist operations - Exports Module

Hello,

I am running Omeka S 4.1.1 on 8.1.2-1ubuntu2.22. We recently installed the Exports module and set up the directory. However, when we try to run any export, we get the following error.

Doctrine\ORM\ORMInvalidArgumentException
A new entity was found through the relationship 'Exports\Entity\ExportsExport#job' that was not configured to cascade persist operations for entity: Omeka\Entity\Job@1968. 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\Job#__toString()' to get a clue.

Details:

Doctrine\ORM\ORMInvalidArgumentException: A new entity was found through the relationship 'Exports\Entity\ExportsExport#job' that was not configured to cascade persist operations for entity: Omeka\Entity\Job@1968. 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\Job#__toString()' to get a clue. in /data/ibali/omeka-s/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:97
Stack trace:
#0 /data/ibali/omeka-s/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(3521): Doctrine\ORM\ORMInvalidArgumentException::newEntitiesFoundThroughRelationships()
#1 /data/ibali/omeka-s/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(390): Doctrine\ORM\UnitOfWork->assertThatThereAreNoUnintentionallyNonPersistedAssociations()
#2 /data/ibali/omeka-s/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(392): Doctrine\ORM\UnitOfWork->commit()
#3 /data/ibali/omeka-s/modules/Exports/Module.php(108): Doctrine\ORM\EntityManager->flush()
#4 /data/ibali/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Exports\Module->Exports\{closure}()
#5 /data/ibali/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(171): Laminas\EventManager\EventManager->triggerListeners()
#6 /data/ibali/omeka-s/application/src/Api/Manager.php(323): Laminas\EventManager\EventManager->triggerEvent()
#7 /data/ibali/omeka-s/application/src/Api/Manager.php(269): Omeka\Api\Manager->finalize()
#8 /data/ibali/omeka-s/application/src/Api/Manager.php(78): Omeka\Api\Manager->execute()
#9 /data/ibali/omeka-s/application/src/Mvc/Controller/Plugin/Api.php(99): Omeka\Api\Manager->create()
#10 /data/ibali/omeka-s/modules/Exports/src/Controller/Admin/IndexController.php(88): Omeka\Mvc\Controller\Plugin\Api->create()
#11 /data/ibali/omeka-s/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(71): Exports\Controller\Admin\IndexController->exportAction()
#12 /data/ibali/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Laminas\Mvc\Controller\AbstractActionController->onDispatch()
#13 /data/ibali/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(179): Laminas\EventManager\EventManager->triggerListeners()
#14 /data/ibali/omeka-s/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(97): Laminas\EventManager\EventManager->triggerEventUntil()
#15 /data/ibali/omeka-s/vendor/laminas/laminas-mvc/src/DispatchListener.php(132): Laminas\Mvc\Controller\AbstractController->dispatch()
#16 /data/ibali/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(319): Laminas\Mvc\DispatchListener->onDispatch()
#17 /data/ibali/omeka-s/vendor/laminas/laminas-eventmanager/src/EventManager.php(179): Laminas\EventManager\EventManager->triggerListeners()
#18 /data/ibali/omeka-s/vendor/laminas/laminas-mvc/src/Application.php(325): Laminas\EventManager\EventManager->triggerEventUntil()
#19 /data/ibali/omeka-s/index.php(21): Laminas\Mvc\Application->run()
#20 {main}

I realise this is similar to some of the previous errors i have already posted about CSV Import gives ORMInvalidArgumentException and BatchEdit and ORMInvalidArgumentException. So I wonder if there is some core issue within our installation, or a particular module that we are using that is causing it. I am afraid i might have to do switch of all modules and see which one causes the problem…

Thank you
Sanjin

Have you customized the job dispatch strategy in your config/local.config.php? That would be an Omeka\Job\DispatchStrategy line under aliases in that file.

Hi @jflatnes,

Thanks for your response.
I change with our IT team and we haven’t done any of those customisations. There is no DispatchStrategy alias set. It is the default one as below in terms of aliases:

'service_manager' => [
        'aliases' => [
            'Omeka\File\Store' => 'Omeka\File\Store\Local',
            'Omeka\File\Thumbnailer' => 'Omeka\File\Thumbnailer\Imagick',
        ],
    ],

You could test this by deactivating all but the Exports module and running an export. If it works, another module was doing something to interfere with its execution .

I suspect that another module is somehow detaching the Job entity from the entity manager, and therefore, when the Exports module attempts to save the export-job relationship, it doesn’t recognize the job as being managed. That’s the error we see above.

One possible fix is to increase the priority of the event that Exports runs after creating an export. You’ll need to edit the Exports/Module.php file in Module::attachListeners():

$sharedEventManager->attach(
    ExportAdapter::class,
    'api.create.post',
    function (Event $event) {
        // leave this code as-is...
    }
    ,1000 // add this line
);

Hopefully, 1000 is a high enough priority for this event to be executed before whatever event is detaching the Job entity. Try it. If it works, we’ve found the problem and I can make the change to the module.

2 Likes

Dear @jimsafley,

Thanks so much for that advice.
I went through the first process, switching off all the modules and got it to work just fine.

I did discover that the active module that causes the error is the Log module. All the other modules can be active, and Exports will run fine. The moment this module is active, the error appears.
On this installation we have Log version 3.4.33, with the below settings:

We did recently install Cron version 3.4.1 with Easy Admin (not sure if this contributes).

I am not sure if we have something not set up properly for our logs, or if i should go and follow your second suggestion… Though I am wondering if this error that is coming from Logs could it also be contributing to certain jobs from the Bulk Edit module that give a similar error message.

Thank you,

Sanjin

I do think the Log module is clearing the entity manager and causing the “A new entity was found” errors you’re seeing. I’m not super familiar with the module, though. You could ask the maintainer for guidance. There’s already an issue on the repository about a similar problem.