If you have a filter that declares 'cache' => 0, then change the definition to remove this, nothing happens. When saving a text_format (either newly created or updated), there's some code to check if it's cacheable or not, so this might eventually get triggered manually, but otherwise contrib modules, if they even know about the bug, would have to work around it. Discovered this when working on #836000: Media filter should not prevent the core text format cache from being used (which has a workaround).

Not sure where the code to rebuild this information should go, or when it should be triggered - I'd say in hook_flush_caches() but that's called on every cron run by system module (which is a problem in itself), so would be a bit wasteful here.

Comments

catch’s picture

Another, related issue from: http://drupal.org/node/836000

if you do this:

$formats = filter_formats();
foreach ($formats as $format) {
  filter_format_save($format);
}

All your filters will be re-saved with status = 0 and their settings completely wiped out.

I had to do this to get the formats to resave properly, which is ugly as hell:


  $formats = filter_formats();
  foreach ($formats as $format) {
    $format->filters = filter_list_format($format->format);
    // filter_format_save() expects filters to be an array, however
    // filter_list_format() gives us objects.
    foreach ($format->filters as $key => $value) {
      $format->filters[$key] = (array) $value;
    }
    filter_format_save($format);
  }

It took a fair bit of debugging to figure out why all my text formats suddenly stopped working. That's probably one for Drupal 8, but it ought to be possible to load and save a format without having to call extra functions to avoid losing data, or at least we should document this very clearly at the top of filter_format_save()

effulgentsia’s picture

subscribe

dave reid’s picture

Version: 7.x-dev » 8.x-dev

Moving to 8.x

cweagans’s picture

Issue tags: +Needs backport to D7
wim leers’s picture

Version: 8.x-dev » 7.x-dev
Issue summary: View changes
Issue tags: -Needs backport to D7

No longer the case in 8.x.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.