Safe Value Missing

Created on 30 June 2020, over 4 years ago
Updated 10 June 2024, 6 months ago

When this text format is applied, it erases the "safe_value" entry for submitted text.

πŸ› Bug report
Status

Active

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kwfinken Lansing, MI

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States jvogt Seattle, WA

    I ran into this too and digging around it looks like it's because the filter has to disable caching (see token_filter_filter_info() in token_filter.module). See text_field_load() in text.module for details on how the safe_value is set. It only sets the safe_value if the filter format allows caching.

    You can get the safe_value manually by passing the value through check_markup():

    // $entity_wrapper is an entity_metadata_wrapper
    $field_value = $entity_wrapper->field_my_field->value();
    $safe_value = $field_value['safe_value'] ?? check_markup($field_value['value'], $field_value['format']);
    

    There's also an open issue with a patch to add a setting to toggle the caching: https://www.drupal.org/project/token_filter/issues/2055307 β†’

Production build 0.71.5 2024