When Drupal invokes hook_filter with $op 'no cache', it does NOT pass $format. I caught this bug when trying out HTML Purifier module, which needs to turn on/off caching for individual formats using the filter (issue for htmlpurifier: #278079: htmlpurifier_doublecache_$format variable is not read correctly ).
To reproduce the bug:
function foo_filter($op, $delta = 0, $format = -1, $text = '') {
switch ($op) {
case 'no cache':
drupal_set_message($format);
return FALSE;
}
}
should output the format ID, e.g. 1, 2, ... It instead outputs -1.
Fixing this would be very easy (just pass the proper variable when invoking hooks), the documentation is ambiguous about this ("no cache: Return true if caching should be disabled for this filter."), can the patch go for Drupal 6.x? The documentation needs updates too.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | invoke-filter-nocache-args.patch | 589 bytes | Leonth |
Comments
Comment #1
Leonth commentedSeems that the patch got lost when I submitted the issue. It is a one-liner!
Comment #2
damien tournoud commentedWell, no. The hook_filter() documentation [1] clearly states:
The caching/no caching of a filter does not depend of the form it is in, at least on Drupal 6. A discussion on implementing more filters that can be aware of their format context is going on for Drupal 7, thou.
[1] http://api.drupal.org/api/function/hook_filter
Comment #3
Leonth commentedSorry for not reading the docs clearly... So... can this go for Drupal 7? At least there is one use case for this feature...
Comment #4
Leonth commentedDigging into that link, it seems to be exactly what I am requesting... sorry