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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | commons-media-features-hooks-2274593-2.patch | 1.31 KB | setvik |
Comments
Comment #1
setvik commentedAttached patch adds conditionals described in issue.
Comment #2
setvik commentedFixed paths in patch
Comment #3
devin carlson commentedRerolled #2 and tested it against an existing Commons install without issue.
Comment #5
setvik commented