In commons_media_filter_default_formats_alter()...

function commons_media_filter_default_formats_alter(&$formats) {
  if (module_exists('media_wysiwyg')) {
    // Allow markup from remote media.
    $formats['filtered_html']['filters']['filter_html']['settings']['allowed_html'] = '<a> <em>...';
  }
}

the $formats['filtered_html'] element is created if it doesn't yet exist, but without the 'name' and 'format' sub-elements necessary for filter_format_save() to save it when features are reverted. Adding a !empty($formats['filtered_html']) conditional fixed it for me.

Likewise in commons_media_ckeditor_profile_defaults_alter()...

function commons_media_ckeditor_profile_defaults_alter(&$profiles) {
  if (module_exists('media_wysiwyg')) {
    // Disable the advanced content filter.
    $profiles['Advanced']['settings']['allowed_content'] = 'f';
  }
}

the $profiles['Advanced'] element is created if it doesn't yet exist, but without the sub-elements necessary for other parts of Drupal to correctly parse it producing an error (i forget the specific fatal error at the moment - I'll try and dig it up and add it to this ticket). Adding a !empty($profiles['Advanced']) conditional fixed this.

I'm not yet certain why those aren't yet populated when this hook fires on the site I'm debugging... It could be a larger issue with my specific site since both the filtered_html filter and Advanced profiles do in fact exist on this site.

That said, it is possible for a site to do away with the filtered_html filter and Advanced profile using these hooks, so commons_media should probably play it safe and check whether they exist before attempting to alter them.

Comments

setvik’s picture

Status: Active » Needs review
StatusFileSize
new1.34 KB

Attached patch adds conditionals described in issue.

setvik’s picture

StatusFileSize
new1.31 KB

Fixed paths in patch

devin carlson’s picture

Status: Needs review » Fixed

Rerolled #2 and tested it against an existing Commons install without issue.

  • Commit d421ca8 on 7.x-3.x authored by setvik, committed by Devin Carlson:
    Issue #2274593 by setvik: Fixed Commons Media doesn't check for the...
setvik’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.