PdfText error when adding new items

Hello,

We have Omeka S 2.1.2 and i have just installed the latest version PdfText module.
It works fine when we add a PDF to an item already registered. However, if it is a new item, on save we get the following error:

Omeka\Api\Exception\NotFoundException: Entidade Omeka\Entity\Item com critério {"id":null} não foi encontrada in /var/www/html/site/application/src/Api/Adapter/AbstractEntityAdapter.php:627
Stack trace:
#0 /var/www/html/site/application/src/Api/Adapter/AbstractEntityAdapter.php(366): Omeka\Api\Adapter\AbstractEntityAdapter->findEntity(Array, Object(Omeka\Api\Request))
#1 /var/www/html/site/application/src/Api/Manager.php(233): Omeka\Api\Adapter\AbstractEntityAdapter->update(Object(Omeka\Api\Request))
#2 /var/www/html/site/application/src/Api/Manager.php(136): Omeka\Api\Manager->execute(Object(Omeka\Api\Request))
#3 /var/www/html/site/modules/PdfText/Module.php(84): Omeka\Api\Manager->update('items', NULL, Array, Array, Array)
#4 /var/www/html/site/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): PdfText\Module->handleApiHydratePostMedia(Object(Zend\EventManager\Event))
#5 /var/www/html/site/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): Zend\EventManager\EventManager->triggerListeners(Object(Zend\EventManager\Event))
#6 /var/www/html/site/application/src/Api/Adapter/AbstractEntityAdapter.php(556): Zend\EventManager\EventManager->triggerEvent(Object(Zend\EventManager\Event))
#7 /var/www/html/site/application/src/Api/Adapter/ItemAdapter.php(190): Omeka\Api\Adapter\AbstractEntityAdapter->hydrateEntity(Object(Omeka\Api\Request), Object(Omeka\Entity\Media), Object(Omeka\Stdlib\ErrorStore))
#8 /var/www/html/site/application/src/Api/Adapter/AbstractEntityAdapter.php(548): Omeka\Api\Adapter\ItemAdapter->hydrate(Object(Omeka\Api\Request), Object(Omeka\Entity\Item), Object(Omeka\Stdlib\ErrorStore))
#9 /var/www/html/site/application/src/Api/Adapter/AbstractEntityAdapter.php(276): Omeka\Api\Adapter\AbstractEntityAdapter->hydrateEntity(Object(Omeka\Api\Request), Object(Omeka\Entity\Item), Object(Omeka\Stdlib\ErrorStore))
#10 /var/www/html/site/application/src/Api/Manager.php(224): Omeka\Api\Adapter\AbstractEntityAdapter->create(Object(Omeka\Api\Request))
#11 /var/www/html/site/application/src/Api/Manager.php(78): Omeka\Api\Manager->execute(Object(Omeka\Api\Request))
#12 /var/www/html/site/application/src/Mvc/Controller/Plugin/Api.php(99): Omeka\Api\Manager->create('items', Array, Array, Array)
#13 /var/www/html/site/application/src/Controller/Admin/ItemController.php(205): Omeka\Mvc\Controller\Plugin\Api->create('items', Array, Array)
#14 /var/www/html/site/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): Omeka\Controller\Admin\ItemController->addAction()
#15 /var/www/html/site/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#16 /var/www/html/site/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#17 /var/www/html/site/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(106): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#18 /var/www/html/site/vendor/zendframework/zend-mvc/src/DispatchListener.php(138): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#19 /var/www/html/site/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#20 /var/www/html/site/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\EventManager\EventManager->triggerListeners(Object(Zend\Mvc\MvcEvent), Object(Closure))
#21 /var/www/html/site/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Zend\Mvc\MvcEvent))
#22 /var/www/html/site/index.php(21): Zend\Mvc\Application->run()

It seems that it is trying to add the property to an item that still doesn’t have an id.
I’ve been looking at the code and noticed that this module attaches an event on:

 $sharedEventManager->attach(
            \Omeka\Api\Adapter\MediaAdapter::class,
           'api.hydrate.post',      
            [$this, 'handleApiHydratePostMedia']
        );

Is there already an id for a new item on the ‘api.hydrate.post’ event, or shoud this operation be executed on a diferent event?

Any help and troubleshooting very greatly appreciated!

It looks like there are a few different “PdfText” modules written/maintained by different people floating around. Your best option is probably to report your issue directly to the Github of the repository where you got the module, to ensure the right person is seeing it.

Apart from any of those, the Omeka team also maintains an S equivalent to the Omeka Classic “PDF Text” plugin, the Extract Text module.

Thank you, jflates, for your quick reply and suggestion.
I have instaled the Extract Text module, and it works fine.
Is there a way to extract the text to already uploaded items?

Thanks,

On the “Items” browse page, select “Edit all” and “Go” (top-left of table). This will take you to the “Batch edit items” page. Beside “Extract text” click the “Refresh text” checkbox and submit the form. This will run a job in the background that should extract text of already uploaded files.

Thanks Jim. I hadn’t noticed that possibility.

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.