Fix Missing startTime Metadata Field Exception #451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed a critical bug where the OpenCast plugin would throw an xoctException with the message "could not find metadata field with id startTime" when uploading content with preview images enabled but timestamp disabled.
Problem
When creating a regular upload event (not scheduled), the startDate and startTime metadata fields are not automatically added to the metadata catalogue. However, the MetadataToXML transformer assumed these fields would always be present, causing the plugin to crash during the upload process.
Fixed a critical bug where the OpenCast plugin would throw an Exception when trying to delete a publication.
Problem
When trying to delete something the HeaderText was not Set.
Stack trace location:
Solution
Modified the MetadataToXML::getXML() method to handle missing startDate and startTime fields gracefully:
Added try-catch blocks around metadata field access
Provides sensible fallback values:
startDate: Current date if field is missing
startTime: 00:00:00 if field is missing
Maintains backward compatibility with existing scheduled events that have these fields
Changes Made
File: src/Util/Transformator/MetadataToXML.php
Added exception handling for missing startDate field (fallback to current date)
Added exception handling for missing startTime field (fallback to 00:00:00)
Added import for xoctException class