Skip to content

Plugin crashes on private items before checking if they're YouTube videos #42

Description

@hklish01

The YouTubeImport plugin crashes when processing exhibit attachments that are private or deleted, even when those items are not YouTube videos. The plugin hooks into filterExhibitAttachmentMarkup which runs on ALL exhibit attachments (images, PDFs, etc.), but it attempts to access item metadata before validating that the item is accessible.

2025-11-06T17:12:17+00:00 ERR (3): InvalidArgumentException: Invalid record passed to recordMetadata. in /var/www/html/omeka/application/views/helpers/Metadata.php:58
Stack trace:
#0 /var/www/html/omeka/application/libraries/Zend/View/Abstract.php(350): Omeka_View_Helper_Metadata->metadata()
#1 /var/www/html/omeka/application/libraries/globals.php(2062): Zend_View_Abstract->__call()
#2 /var/www/html/omeka/plugins/YouTubeImport/YouTubeImportPlugin.php(159): metadata()
#3 /var/www/html/omeka/application/libraries/Omeka/Plugin/Broker.php(266): YouTubeImportPlugin->filterExhibitAttachmentMarkup()
#4 /var/www/html/omeka/application/libraries/globals.php(324): Omeka_Plugin_Broker->applyFilters()
#5 /var/www/html/omeka/plugins/ExhibitBuilder/views/helpers/ExhibitAttachment.php(62): apply_filters()
#6 /var/www/html/omeka/application/libraries/Zend/View/Abstract.php(350): ExhibitBuilder_View_Helper_ExhibitAttachment->exhibitAttachment()
#7 /var/www/html/omeka/plugins/ExhibitBuilder/views/shared/exhibit_layouts/gallery/layout.php(20): Zend_View_Abstract->__call()
#8 /var/www/html/omeka/application/libraries/Omeka/View.php(114): include('...')
#9 /var/www/html/omeka/application/libraries/Zend/View/Abstract.php(889): Omeka_View->_run()
#10 /var/www/html/omeka/application/libraries/Zend/View/Helper/Partial.php(109): Zend_View_Abstract->render()
#11 /var/www/html/omeka/application/libraries/Zend/View/Abstract.php(350): Zend_View_Helper_Partial->partial()
#12 /var/www/html/omeka/plugins/ExhibitBuilder/helpers/ExhibitPageFunctions.php(33): Zend_View_Abstract->__call()
#13 /var/www/html/omeka/plugins/ExhibitBuilder/views/public/exhibits/show.php(10): exhibit_builder_render_exhibit_page()
#14 /var/www/html/omeka/application/libraries/Omeka/View.php(114): include('...')
#15 /var/www/html/omeka/application/libraries/Zend/View/Abstract.php(889): Omeka_View->_run()
#16 /var/www/html/omeka/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(912): Zend_View_Abstract->render()
#17 /var/www/html/omeka/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(933): Zend_Controller_Action_Helper_ViewRenderer->renderScript()
#18 /var/www/html/omeka/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php(972): Zend_Controller_Action_Helper_ViewRenderer->render()
#19 /var/www/html/omeka/application/libraries/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
#20 /var/www/html/omeka/application/libraries/Zend/Controller/Action.php(527): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
#21 /var/www/html/omeka/application/libraries/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch()
#22 /var/www/html/omeka/application/libraries/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch()
#23 /var/www/html/omeka/application/libraries/Zend/Application/Bootstrap/Bootstrap.php(106): Zend_Controller_Front->dispatch()
#24 /var/www/html/omeka/application/libraries/Zend/Application.php(384): Zend_Application_Bootstrap_Bootstrap->run()
#25 /var/www/html/omeka/application/libraries/Omeka/Application.php(73): Zend_Application->run()
#26 /var/www/html/omeka/index.php(23): Omeka_Application->run()
#27 {main}

When items are private or deleted, $attachment->getItem() returns null due to ACL restrictions. The code immediately calls metadata($item, ...) with a null value, causing the exception.

Adding this validation at line 157 appears to fix the issue:

/ Handle null or inaccessible items (private items, deleted items, etc.)
if (!$item || !($item instanceof Omeka_Record_AbstractRecord)) {
return $html;
}

Omeka 3.1.1
YouTubeImport 1.3

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions