omeka-s-modules / Osii

Import items from other Omeka S installations
GNU General Public License v3.0
2 stars 0 forks source link

Ossi fails after 200 items #9

Closed pprw closed 1 year ago

pprw commented 1 year ago

After successfully imported 200 items, Osii fails to import metadata for the other ones (media are imported though)

2023-06-12T20:54:22+00:00 ERR (3): Doctrine\ORM\ORMInvalidArgumentException: A new entity was found through the relationship 'Omeka\Entity\Resource#owner' that was not configured to cascade persist operations for entity: DoctrineProxies\__CG__\Omeka\Entity\User@659. 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 /sites/vendor/doctrine/orm/lib/Doctrine/ORM/ORMInvalidArgumentException.php:97
Stack trace:
#0 /sites/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(3520): Doctrine\ORM\ORMInvalidArgumentException::newEntitiesFoundThroughRelationships()
#1 /sites/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(390): Doctrine\ORM\UnitOfWork->assertThatThereAreNoUnintentionallyNonPersistedAssociations()
#2 /sites/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(392): Doctrine\ORM\UnitOfWork->commit()
#3 /sites/modules/Osii/src/Job/AbstractOsiiJob.php(173): Doctrine\ORM\EntityManager->flush()
#4 /sites/modules/Osii/src/Job/DoImport.php(300): Osii\Job\AbstractOsiiJob->flushClear()
#5 /sites/application/src/Job/DispatchStrategy/Synchronous.php(34): Osii\Job\DoImport->perform()
#6 /sites/application/src/Job/Dispatcher.php(105): Omeka\Job\DispatchStrategy\Synchronous->send()
#7 /sites/application/data/scripts/perform-job.php(66): Omeka\Job\Dispatcher->send()
#8 {main}

Omeka S version 4.1.0-alpha5 (master) (harvested Omeka S is 3.2.1 Omeka S Item Importer version 1.2.0

jimsafley commented 1 year ago

It's a puzzling error given that the import doesn't really do anything interesting with resource owner. It just assigns the resource to the user who started the import. I haven't encountered this error during my extensive testing, so troubleshooting could be tricky.

These kinds of errors can happen due to an incompatibility with another module. Try deactivating every module but OSII and running another import. That may fix it.

Another thing you could try is open the file ResourceOwner.php and comment out this line:

// $localResource['o:owner']['o:id'] = $this->getJob()->getJobEntity()->getOwner()->getId();

Save and run another import. It could be that the job owner is not getting merged back into the entity manager after clearing it. This would account for a "A new entity was found" error. But it still wouldn't explain why no one else has had the same error.

pprw commented 1 year ago

I tried both deactivate all modules but Osii and commenting the line in ResourceOwner.php.

Same problem in both cases.

jimsafley commented 1 year ago

Yes, quite puzzling. Can you share the remote API that you're attempting to import? It'll be much easier to fix if I can reproduce the error.

jimsafley commented 1 year ago

@pprw We successfully reproduced the error using the API endpoint you provided. However, we're having a hard time finding an explanation. It's probably not related to the ResourceOwner mapper, or to an un-merged job owner. The error appears to happen when importing the last item (#2723) with values. We're looking possible reasons. We'll keep you updated on our progress.

pprw commented 1 year ago

I tried to exclude item #2723 from the imported content.

Without this item, import completed without error.

This item contains value annotations binden to dcterms:title (two URI)

image

jimsafley commented 1 year ago

Yes, value annotations are definitely the culprit, but for a rather esoteric reason. We should have a fix in the coming days.

jimsafley commented 1 year ago

The simulated-clear branch should fix the bug. Feel free to check it out and confirm that the import works. You should probably first delete the items, media, and item sets from your original import. That's as easy as clicking on the "View..." links in the "Manage import" sidebar and batch deleting them.

At any rate, we're going to continue testing the branch and make a bugfix release by the end of the week.

pprw commented 1 year ago

I just tested and I can confirm it is working with the simulated-clear branch

Thanks!

jimsafley commented 1 year ago

@pprw Thank you for reporting the bug and testing the fix. We've make a new release. It should be published tomorrow.