Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Remove the concept of numeric deltas and use unique filters' names to declare and identify filters. Instead of using hardcoded numeric deltas and $module/$delta
pairs to reference filters, an unique name, namespaced in the module that provides the filter should be used.
See #216072: DROP Task: Remove hardcoded numeric deltas from all hook_block() implementations in core for reference.
Example:
function filter_filter_info() {
$filters['filter_html'] = array(
'name' => t('Limit allowed HTML tags'),
'description' => t('Allows you to restrict the HTML tags the user can use. It will also remove harmful content such as JavaScript events, JavaScript URLs and CSS styles from those tags that are not removed.'),
'process callback' => '_filter_html',
'settings callback' => '_filter_html_settings',
'tips callback' => '_filter_html_tips'
);
$filters['filter_autop'] = array(
'name' => t('Convert line breaks'),
'description' => t('Converts line breaks into HTML (i.e. <br> and <p>) tags.'),
'process callback' => '_filter_autop',
'tips callback' => '_filter_autop_tips'
);
$filters['filter_url'] = array(
'name' => t('Convert URLs into links'),
'description' => t('Turns web and e-mail addresses into clickable links.'),
'process callback' => '_filter_url',
'settings callback' => '_filter_url_settings',
'tips callback' => '_filter_url_tips'
);
$filters['filter_htmlcorrector'] = array(
'name' => t('Correct broken HTML'),
'description' => t('Corrects faulty and chopped off HTML in postings.'),
'process callback' => '_filter_htmlcorrector',
);
$filters['filter_html_escape'] = array(
'name' => t('Escape all HTML'),
'description' => t('Escapes all HTML tags, so they will be visible instead of being effective.'),
'process callback' => '_filter_html_escape',
'tips callback' => '_filter_html_escape_tips'
);
return $filters;
}
Postponed as it is dependent of #546336: hook_filter_info(): Remove $op from hook_filter()
Comment | File | Size | Author |
---|---|---|---|
#14 | remove-numeric-deltas-14.patch | 19.41 KB | dropcube |
#11 | remove-numeric-deltas-11.patch | 18.47 KB | dropcube |
#9 | remove-numeric-deltas-9.patch | 18.59 KB | dropcube |
#6 | remove-numeric-deltas-6.patch | 17.5 KB | dropcube |
#3 | remove-numeric-deltas.patch | 16.77 KB | dropcube |
Comments
Comment #1
dropcube CreditAttribution: dropcube commentedComment #2
catchsubscribing.
Comment #3
dropcube CreditAttribution: dropcube commentedThe patch removes hardcoded numeric deltas and uses a literal filter ID, prefixed with the module name of the module that provided the filter.
Comment #5
dropcube CreditAttribution: dropcube commentedComment #6
dropcube CreditAttribution: dropcube commentedUpdated patch.
Comment #7
moshe weitzman CreditAttribution: moshe weitzman commentedWow, this is great. Numeric IDs are a real big problem when sharing Views or Features or anything like that. Hope this gets some testers. Subscribe.
Comment #8
Dries CreditAttribution: Dries commented- People expect ids to be numeric. For string ids, we usually use 'name'. Shall we rename 'filter_id' to 'name'?
-
+ 'fmd' => array('format', 'module', 'filter_id'),
-- the 'd' in fmd stood for delta, so maybe that needs to be renamed too.- No update function yet?
Comment #9
dropcube CreditAttribution: dropcube commentedUpdated patch.
- 'filter_id' is now 'name', the name of the filters provided by modules.
- the 'name'key in the filter definition, is now 'title', the human readable title of the filter.
- added update function.
Comment #11
dropcube CreditAttribution: dropcube commentedwrong patch, here is the correct one.
Comment #12
dropcube CreditAttribution: dropcube commentedComment #14
dropcube CreditAttribution: dropcube commentedUpdated fixing tests failures.
Comment #15
moshe weitzman CreditAttribution: moshe weitzman commentedI read through again and this looks sane still.
Is there a patch to move *formats* from numeric IDs to strings? Thats important too.
Comment #16
catchThe core update path only deals with core filters, will contrib modules have to do the same upgrade path themselves operating on filter.module tables?
Comment #17
dropcube CreditAttribution: dropcube commentedFor now, yes. Each module should know by itself which are it's renamed deltas. See http://api.drupal.org/api/function/system_update_7004/7
Comment #18
catchOk that makes sense and I couldn't see a way around it, but worth checking. We should make doubly sure to mention this in the upgrade docs (and for blocks too).
Comment #19
Dries CreditAttribution: Dries commentedI've reviewed this patch several times, and it still looks good. Committed.
Comment #20
dropcube CreditAttribution: dropcube commentedWe should mention this in the upgrade docs, and explain how modules implementing
hook_filter_info()
should upgrade.Comment #21
dropcube CreditAttribution: dropcube commentedComment #22
yrocq CreditAttribution: yrocq commentedChanges are already documented here : http://drupal.org/update/modules/6/7#hook_filter_info .
#d7csmtl