Problem/Motivation
I've faced numerous errors when a citation is rendered due to invalid data (e.g. broken dates like 11/200). The import process lacks validation, entities have built in validation using field constraints but these are never called during import.
Steps to reproduce
Prepare a special file in any format your site accepts, use invalid data like a invalid date. Import the file on the site and view the created reference, depending on the citation style a fatal error might occur.
Proposed resolution
Use Entity Validation API to check if the entity is valid before saving it https://www.drupal.org/docs/drupal-apis/entity-api/entity-validation-api...
Remaining tasks
Tests?
User interface changes
None
API changes
None
Data model changes
None
Issue fork bibcite-3553399
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
apugacescu commentedAdded proposed validation trigger.
Comment #4
mark_fullmerComment #5
mark_fullmerI confirmed the lack of validation as described above, and confirmed that the proposed code change does run the imports through existing entity validation. I just made a couple adjustments to surface the error messages directly in the UI, rather than only showing them in the Drupal logs. Thanks for the bug report and the fix!
I suppose it's possible that some people will consider this added validation to be a hindrance, rather than an improvement, if they would prefer to import invalid entries and deal with them after the fact. But I agree that it is more appropriate to flag any known problems prior to import, so we'll go with this change and just be sure to call out this clearly in the release notes.