Have been thinking about this for a while but a conversation in irc just reminded me.
Filters are usually very expensive, one filter that sets 'cache' => 0, prevents all other filters from being cached in check_markup().
Instead of this, we could enforce that cacheable filters run first, then non-cacheable filters run on the cached string.
This way, one badly behaved (or just very tricky) filter, can't spoil things for everyone else.
There is a chance you might want to allow uncacheable filters to run before some others, it would be conceivable to run them on the raw string, then cache based on that processed string, then run other uncacheable filters on the cached string afterwards. I can't think of any that would need to do this but that'd be about as flexible as what we have now, without the overhead of running every filter every time.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | remove_filter_cacheability-1191938-21.interdiff.txt | 774 bytes | blueminds |
| #21 | remove_filter_cacheability-1191938-21.patch | 13.74 KB | blueminds |
| #19 | remove_filter_cacheability-1191938-19.patch | 15.3 KB | blueminds |
Comments
Comment #1
e2thex commentedI think this would be awsome, I am currently trying to make a general box embed module, that would let one in embed a box in a content field.
The main issue we run into is as there is no connection from the node to the box, it the box change there is no way to say clear the cache on the node. It would be very nice if we could add the box after the content is cached. We had the same issue in d6 with the node_embed module.
Comment #2
catchBumping to major, now that we have #post_render_cache, and render caching of entities by default, there's less and less reason for this.
Comment #3
wim leersRunning uncacheable filters last implies we ignore filter order for uncacheable filters, which could break things? And if we allow filters to do things dynamically via
#post_render_cache, then why do we need this at all?I think that's what you're getting at in #2 when you say "less and less reason for this": when #2217877: Text filters should be able to add #attached, #post_render_cache, and cache tags lands, we can just *remove* the ability for filter plugins to indicate they're not cacheable.
Please confirm or clarify :)
Comment #4
catchYep, better issue title :)
Comment #5
blueminds commentedMy humble try... please see the patch.
Comment #7
wim leers#5: thanks for the patch! I independently worked on this too (as part of #2217877: Text filters should be able to add #attached, #post_render_cache, and cache tags), here's my version. Let's help each other get this one to RTBC :)
Comment #9
blueminds commentedRerolled/merged. Let's see if testbot likes.
Comment #10
wim leersYou lost this from #7.
Other than that, it looks good I think :)
Comment #11
blueminds commentedThanks, updated.
Comment #12
wim leersThe original code says: "if text processing is disabled, or if text processing is enabled but none of the filters in this text format disables filtering, then generate a cached value".
We've changed that to "if text processing is disabled, then generate a cached value".
This is wrong.
This entire if-statement can go away! :)
Comment #13
wim leersComment #14
blueminds commentedUpdated the patch.
Comment #15
wim leersThere are a few more leftovers to be done before I can RTBC this:
filter.format.*.ymlfiles.filter.schema.ymlshould be updated also.FilterFormatstill has a$cacheproperty.FilterInterfacestill listscacheas an annotation propertyFilterDefaultConfigTestis still testing$this->assertEqual($format->get('cache'), 1);, which is passing today because of point 1.(Discovered while working on #2217877-22: Text filters should be able to add #attached, #post_render_cache, and cache tags.)
Comment #16
blueminds commentedThanks for the list. All removed.
Comment #17
blueminds commentedComment #19
blueminds commentedtestFilterAdminClearsFilterCache() is probably not needed anymore as well.
Comment #20
wim leersNo, #19 is wrong: we are not removing the filter cache here, so you cannot remove the test coverage either.
Since #16 failed, that means this patch introduces a regression somewhere, as demonstrated by the failure in
testFilterAdminClearsFilterCache().Once you've fixed that failure, I can RTBC this :)
Comment #21
blueminds commentedOh, right.
The reason for the fail was that logic in computeFilterCacheId() still accounted for the $format->cache.
Comment #22
blueminds commentedbumping this up
Comment #23
wim leers#2217877: Text filters should be able to add #attached, #post_render_cache, and cache tags went in, which includes what this patch does and more. I'm very sorry, but this is no longer necessary.