Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
filter.module
Priority:
Critical
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
29 Aug 2009 at 06:03 UTC
Updated:
3 Jan 2014 at 00:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
lilou commentedHEAD is broken.
Comment #3
ugerhard commentedreroll
Comment #5
sunLooks good, but testbot bailed out again for any reason.
Comment #6
dropcube commentedHey bot, try again.
Comment #7
sunPHP summary should be on one line.
I think the function name should be filter_format_is_cacheable() for extra clarity.
It would make sense to pass a $format object instead and let the helper function iterate over the contained (enabled) filters.
Also note the trailing white-space. (and elsewhere)
It's not entirely clear to me what "an array of filter names" means. Can we clarify that? :)
This comment could be a bit more clear; f.e. By default, 'cache' is TRUE for all filters unless specified otherwise.
Lastly, it looks like this functionality should be covered in a test, so we don't break it again. :)
I'm on crack. Are you, too?
Comment #8
sunIntroducing a new tag for feature freeze: API clean-up.
Comment #9
dries commentedLooks good, and I agree with sun's comment.
In addition, we should make the difference between filter_format_is_cachable() and filter_format_allowcache() more clear. We might have to rename filter_format_allowcache().
Comment #10
dropcube commentedThinking better, filter_format_is_cachable() does not seem a good name, the format is not cacheable, but the text in a certain text format is *allowed* to be cached.
I think we should keep filter_format_allowcache(), which is a good name, and just add a helper function to determine if text in a given text format can be cached, before saving the result to the database.
Working on the patch...
Comment #11
sunNot sure whether we need another helper function for this.
We should additionally clarify when to use which function (in this approach), because if they happen to be invoked in a unintended order, then we'd end up in an endless loop (filter_format_load() invoked during filter_format_save()...)
Additionally, filter_format_save() already iterates over all filters, so we might just have to change the order of storage (which sounds unorthodox, but shouldn't affect anything).
I'm on crack. Are you, too?
Comment #12
sunAlso, seems like we should tackle + commit #562908: {filter}.module is not saved first.
Comment #13
dropcube commentedHere is an updated patch:
- Added helper function to determine if a text format allow cache, depending on the filters enabled.
Reworked the tests
- There is some confusion around filters/formats, seems they are being used indistinctly.
- Added some randomization to the test, to make them more general and accurate.
- Added test to check if formats allow cache.
Comment #14
sunThanks!
However, I'd like to defer that test clean-up to #573852: Rename {filter_format}.name to .title and replace .format with machine-readable .name -- the entire filter.test file gets "filters" and "formats" completely wrong. Which is, btw, quite interesting: Not only users don't get it, but also developers/test writers obviously had no clear idea of what exactly they were testing...
Comment #15
dropcube commentedI included the test clean-up here because testing if a format allow cache, with two hardcoded filters enabled, both allowing cache, is really worthless. Still needs some work, though.
So, I am going to create a patch for that issue with the test clean-ups.
Comment #16
sunTagging absolutely critical clean-ups for D7. Do not touch this tag.
Comment #17
sunI just realized that this patch contains an API change... :( This it absolutely has to be done before 10/15.
Can we quickly re-roll #13 without any test clean-ups?
Comment #18
sunRe-rolled the essentials - without tests. Not sure how to test this yet.
Comment #20
sunheh... nice if bugs are totally obvious by reviewing the patch. ;)
Comment #22
sunPassing the tests.
Comment #24
sunComment #25
sunLet's get this in.
Comment #26
dries commentedI think the difference between filter_format_allowcache() and _filter_format_allowcache() is confusing. Can be find better names for those, or can we merge them somehow?
I guess this means the "text output by a given text format" rather than the text format itself?
Comment #27
sunI can see how this could be confusing. But well, these two functions are really completely different functions.
The private function is only used by filter_format_save() to determine whether a format that is about to be saved - and may not exist in the database yet - supports caching.
The public function, filter_format_allowcache(), exists for a long time already, and takes a $format_id only, so it can be used by modules in other situations. For example, text.module calls this function to determine whether it can cache the content of a text field for rendering.
I don't want to introduce an API change by renaming filter_format_allowcache() in here.
But, I also don't want to inline the code of the private function into filter_format_save(). So I hope that renaming the private function to _filter_format_is_cacheable() is sufficient to get this done.
.
This time, also including tests to make sure we don't break this again.
Comment #28
dries commentedAlright. Can't think of a better name either. Committed to CVS HEAD -- we have to move forward.