Import does not set default value for abstract text format

Created on 11 January 2024, 6 months ago
Updated 8 May 2024, about 2 months ago

Problem/Motivation

When a reference with an "abstract" field is imported, there is no handling of the text format, only the value. This results in a NULL value being populated into the database column for the text format, and the abstract rendering as plain text.

This can be further confusing if the reference is subsequently edited via the UI: Drupal will populate the first available text format as the default (such as "Basic HTML") giving the impression that there is a text format assigned. Upon save, the reference's abstract will now use the text format, creating a different output that prior to saving.

Steps to reproduce

1. Enable the `bibcite_import` module and the `bibcite_bibtex` module.
2. Import a simple reference with an abstract field that contains HTML, such as shown below, in BibTex format:

@misc{1,
  title = {test},
  abstract = {<p><strong>test123</strong></p>},
  year = {2005},
}

3. After the import is completed, view the reference. It will render the value of the abstract with encoded HTML, as in <p><strong>test123</strong></p>, applying no Drupal text format rendering.

Proposed resolution

During entity save, check if the abstract has a value and the text format has no value, which would be the case for all imports. If so, look up the highest-weighted text format in the site (via filter_formats()) and set the text format to that format. This will effectively provide a reliable fallback format, matching site configuration.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024