Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
filter.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Jun 2014 at 14:53 UTC
Updated:
13 Aug 2014 at 12:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
alexpottPatch to show how to cause the problem
Comment #2
yched commentedIs this something specific to FilterFormat entities, or is there a generic pattern / issue here ?
Comment #4
effulgentsia commentedIt's specific to filters due to them not implementing plugin instances the same way as elsewhere - for filters, the plugin id is also the instance id, so there's no instance create/delete cycle in the API or UI.
Don't know if there's another plugin system / config entity in core that has a similar problem, but it's definitely not the typical case.
Comment #5
alexpottHere's a patch that does exactly what the @todo wants and fixes the bug.
Comment #6
alexpottComment #8
alexpottAdded tests and fixed the exceptions.
Comment #11
alexpottFix up the tests.
Comment #12
yched commentedI'll let other people more familiar with the filter system RTBC this but :
This comment cannot be copy/pasted as is from FilterFormat::preSave() :-)
Comment #13
alexpottYep that comment is not necessary considering the function's docblock.
Comment #14
sunIncomplete review:
We don't need to retrieve
$defaultif the filter is enabled.Comment #15
alexpottGood point.
Comment #16
alexpottWe can remove the hack in standard.install now :)
Comment #17
wim leers#16: lovely!
I could only find nitpicks:
This scares me.
s/customise/customize/, I fear… here and elsewhere. I'd prefer UK English also, but alas.
Language errors.
While I think this is funny, wouldn't it be better if this were named
getCustomizedFilters()?This could also be a static method.
Oh… this is a helper in a test class. Let's keep the funkiness then! :P
Comment #18
alexpottComment #19
tim.plunkettWe do a similar thing for conditions, but completely differently. See ConditionPluginBag::getConfiguration().
Comment #20
wim leersComment #21
chx commentedphp, loosely typed, readability, yadda yadda :D
Comment #22
tim.plunkettI don't think this is RTBC yet, see #19.
Comment #23
alexpottDiscussed with @tim.plunkett on IRC -
FilterBase::defaultConfigurationcurrently is a bit weird. This patch makes minimal changes to fixes this issue - #2309961: Filter plugins should use defaultConfiguration() properly will make further changes to brings filters into line with other plugins.Comment #24
tim.plunkettI don't know that we need this anymore?
Comment #25
alexpottReverted all changes to ConfigEntityImportTest and moved the removal into FilterBag::getConfiguration
Comment #26
tim.plunkettThe last patch is green, it might not look like it because of #2310011: Comment render caching breaks comments with patches attached
Comment #27
tim.plunkett#2310023: Do not export plugin configuration if it matches the defaults works to move that shared code out of FilterBag and ConditionPluginBag directly into DefaultPluginBag.
Comment #28
catchWhat happens here if a module updates the defaults, it'll change the behaviour of existing text formats in the system when they're not customized no?
Comment #29
dawehnerOnce you deployed a config with default values these defaut values won't be part of the active config.
If you as a filter plugin developer want to change default values, this would automatically change the behavior of all these default values
based input formats.
In practice this means that you as a core/contrib developer cannot change default values anymore.
As catch pointed out in IRC this is especially critical in the land of input formats as it could lead to potential security issues.
If you store all configs all the time, changing the default values would have no impact on active behaviour.
If you want on the other hand change the behavior of all the things, you could write an update script
or for custom world simply change all those configurations manually.
Note: This is the normal behavior of CMI.
Storing everything gives you the flexibility to change the default values later, which was always problematic
in contrib world (views for example).
Comment #30
Anonymous (not verified) commented#28 and #29 +10000000000
Comment #31
alexpottHmmm... this is not that simple. Look at the current hack in standard.install
If I install a module that provides a filter plugin should it resave every existing filter format to add it's disabled plugin configuration?
Comment #32
alexpottAlso if changing the default values of a disabled filter plugin represents a security issue - I'm scratching my head. I do think that we should ensure that filter plugins are disabled by default.
Comment #33
alexpottFor clarity - the status of the plugin is part of the "default configuration" - no filter plugin in enabled by default. The moment you enable the plugin it is saved in config and changing the programatic defaults has no effect.
Comment #34
catchHmm OK, so should the title be 'should not save plugin data when plugins are disabled' then?
How do we know whether this is an enabled plugin that happens to have configuration matching the defaults, or a disabled plugin that has not been configured at all? Purely because the status is part of that default configuration, so if it's enabled it must be configured? Because then it wouldn't match the defaults? Needs much more explanation in the code at least. Do we have anything that ensures filters are disabled by default?
Comment #35
alexpottThis ensures that they are disabled by default.
I'll add a comment there that this is important. And I'll also add a comment about how saving disabled plugin configuration when it has been customised is a good thing too.
Comment #36
Anonymous (not verified) commented"If I install a module that provides a filter plugin should it resave every existing filter format to add it's disabled plugin configuration?"
i think this means - every new filter plugin, disabled or not, forces changes in every existing filter format? did we take a wrong turn somewhere?
i guess i'm missing the big picture on how that makes any sense at all.
Comment #37
alexpott#36 we will only be taking this wrong turn if we don't commit this patch. This patch prevents disabled filter plugins from newly installed modules affecting existing filter format config entities.
Comment #38
tim.plunkettI agree we do need to be careful when suppressing config output. However, filters are a special case here, and because the default values include
'status' => FALSE, this is safe.But based on @dawehner and @catch's points, we should probably close #2310023: Do not export plugin configuration if it matches the defaults.
ConditionPluginBag has the same hack, but also because it currently hardcodes the available conditions...
Comment #39
Anonymous (not verified) commenteddiscussed this with timplunkett. he explained to me that what this patch does is stop the crazy runtime filter stuff from bleeding through to CMI writes.
and code changes shouldn't change behaviour, because the magic instances that are added are all disabled.
so. kinda crazy, but i think i'm satisfied with this.
Comment #40
dawehnerCan we please document why this is okay, but just okay for filter module?
Comment #41
tim.plunkettYes, good point.
Comment #42
yched commentedNot sure about other plugins, but Field API explicitly avoids "change of code-defined defaults changes the behavior of fields / widgets / formatters that already exist". Defaults are only used as "initial settings on creation" (or fallback value in case a setting is added to a field type and was unknown / not specified in pre-existing fields). We never change behavior behind site admin's back.
Comment #43
effulgentsia commentedTo clarify, what makes FilterFormat a special snowflake is that:
The combination of the above (autoinstantiate + retain config for disabled) creates the problems we currently have in HEAD, where code changes can leak config updates at unpredictable times, and cause formats to have unwanted dependencies on modules that came about without any user action or benefit to the user, that necessitates the fix in this issue.
Comment #45
catchOpened #2312379: Bring filter format plugin configuration into line with other systems.
Committed/pushed to 8.x, thanks!
Also posthumously tagging D8 upgrade path since we'd have needed to update existing formats if we were supporting that yet.
Comment #46
benjy commentedI was just working on a new install profile and I found a @todo in standard.install, came to the issue and it got committed an hour ago :)
Anyway, we should now be able to remove this from standard.install
Comment #47
benjy commentedMy mistake, looks like I didn't change to 8.0.x