Spin off from #1975112: Config schema mechanisms cannot reflect alterable config trees and #2130811-17: Use config schema in saving and validating configuration form to ensure data is consistent and correct .
Currently, the collection of available "settings" for a field/instance/widget/formatter are part of field type/widget/formatter plugin definition (in annotations), and are thus alterable like the rest of the plugin definition.
In D7, a lot of contrib modules have used that to add new "settings" of their own, that thus get conveniently saved and loaded along field/instance/widget/formatter definitions.
In current core D8, content_translation does the same to add its 'translation_sync' field setting, applicable to all field types.
Problem: there is no way to provide config schema for this (detailed explanation / discussion in #1975112: Config schema mechanisms cannot reflect alterable config trees).
This was discussed back in Portland, and this is now a major issue because #2130811: Use config schema in saving and validating configuration form to ensure data is consistent and correct relies heavily on config schema info.
Summary of the discussion in Portland:
- A config entity cannot hold properties it doesn't know about, because then it cannot provide a schema for them. The rule is : "if you have additional settings of your own to store about my config entity, store them yourselves in your own config records for which you can provide a schema".
- More specifically, the config schema for the 'settings' part of a field/instance/widget/formatter configuration is statically provided by the module providing the field type/widget/formatter, and the schema mechanism doesn't let any other 3rd party code provide additional schema info about it. We cannot ask *all* field type modules to provide schema info about the 'translation_sync' property that *might* be present in field.field.*.yml CMI files in case c_t.module is enabled.
- Those "extra settings" are in fact not settings for the plugin anyway, since the plugin class won't suddenly and magically know and use them. They are actually settings for 3rd party code (typically implementations of hooks fired when after the plugin did its job), and storing them in 'settings' is only a convenient way to have free storage and loading. But we just can't support that in D8 anymore.
[edit: #2005434: Let 3rd party modules store extra configuration in EntityDisplay is here to bring this functionnality back for widgets & formatter settings in EntityDisplay config entities, in a structured way that allows config schema - see over there why it makes sense for widgets & formatters]
Consequences:
- The set of supported field/instance/formatter/widget settings, should *not* be alterable, and we should probably remove them from the plugin definitions (that's what makes them alterable) and into static methods in the plugin classes (that's how Views always did it).
- In the case of content_translation, it means 'translation_sync' should not be an altered-in field setting, but a separate piece of config, associated to a given [entity_type, bundle, field_name], tracked and managed by content_translation whichever way it sees fit.
Coding happens in 2136197-settings-annotations-remove branch
Comment | File | Size | Author |
---|---|---|---|
#133 | 2136197-follow-up.patch | 794 bytes | andypost |
#130 | remove-settings-annotation-2136197-130.patch | 99.18 KB | swentel |
Comments
Comment #1
yched CreditAttribution: yched commentedNote: For "extra settings" for widgets and formatters specifically, the "store them yourself" mantra is tricky because of the "per view mode" & "default display" logic specific to entity displays. So having those "extra settings" stored in the EntityDisplay somehow would really be a bonus. It just can't be in "settings", and needs to be in a separate entry, clustered by 'providing module', so that we can route to the correct schema info.
This is what #2005434: Let 3rd party modules store extra configuration in EntityDisplay is for.
Comment #2
yched CreditAttribution: yched commented@alexpott: not fully sure this will solve #2130811: Use config schema in saving and validating configuration form to ensure data is consistent and correct though.
In the scenario described above, c_t's 'translation_sync' property would still be form_altered into the "Field edit form", it would just be saved to a separate c_t config file instead of field.field.*.yml. Would #2130811: Use config schema in saving and validating configuration form to ensure data is consistent and correct still be able to masssage submitted values according to the correct schema in this case ?
Comment #3
yched CreditAttribution: yched commentedComment #4
yched CreditAttribution: yched commentedComment #5
xjmBased on #2005434: Let 3rd party modules store extra configuration in EntityDisplay #11 - #13, this should have been tagged as a beta blocker, as it impacts both the config schemata data model and the configurable field API.
Comment #6
swentel CreditAttribution: swentel commentedInitial patch converting field formatters .. this will break the tests we have for field formatter settings alter, so should we comment this out and bring those back in #2005434: Let 3rd party modules store extra configuration in EntityDisplay ? Could use a go on the approach .. :)
Code is in 2136197-settings-annotations-remove branch
Comment #7
swentel CreditAttribution: swentel commentedComment #8
yched CreditAttribution: yched commentedYay, thanks for picking this up !
At this point in the cycle, though, I'm not too hot on renaming "settings" to "options" - we have a whole collextion of methods named xxSettings() / xxSetting() all over the place for widgets, formatters, field types...
Comment #10
swentel CreditAttribution: swentel commentedRight, I copy/pasted from views just to see how fast I could get this into a patch. I'm going to fix the test failures first (which are not formatter-alter related) and then come up with a better name, maybe hasSettings (boolean) and settings() ? Suggestions welcome.
Comment #11
swentel CreditAttribution: swentel commentedComment #13
swentel CreditAttribution: swentel commentedStart on widgets as well
Comment #15
swentel CreditAttribution: swentel commentedAnnotations--
Comment #17
swentel CreditAttribution: swentel commentedComment #19
longwaveNodeConditionTest fails due to #2170471: ContextAwarePluginBase compromised after commit of Core PluginBase
Comment #20
longwaveFixed ManageDisplayTest and PictureFormatter
Comment #21
longwaveRemoved settings annotation from TextSummaryOrTrimmedFormatter
Comment #24
longwaveNodeConditionTest passes if I apply the patch from #2170471-18: ContextAwarePluginBase compromised after commit of Core PluginBase, so here's a combined patch to see what testbot thinks.
Comment #25
swentel CreditAttribution: swentel commented@longwave: Thanks for working on this! Any chance you could push to our field api sandbox - http://drupal.org/node/1736366 - In branch 2136197-settings-annotations-remove - I just gave you access, that would be awesome!
Comment #26
longwaveDone - the small fixes I made in #20 and #21 are in the sandbox now. I haven't pushed the NodeConditionTest fix as that belongs to the other issue.
Comment #27
BerdirIf this issue provides implict test coverage and the other issue is apparently blocked on having test coverage (and has been for a long time), then it might be easier to just merge it in here and move on. Otherwise you need to make that other issue a critical beta blocker, as it blocks one and come up with an arbitrary test for it or delay test coverage on this issue.
Comment #28
swentel CreditAttribution: swentel commentedOk, renamed the defineOptions to settings() which makes more sense, especially in light of moving the field and instance settings of field types in methods too.
Hope I got them all. Working on the field types now, which seems to be a little trickier.
Comment #30
yched CreditAttribution: yched commentedComment #31
yched CreditAttribution: yched commentedComment #32
dawehnerJust an idea of a follow up: We could provide a base class for field module plugins managers.
It would be great if we describe how settings look like. Yeah an array, so probably key => default_value ?
Comment #33
Wim Leerss/$plugin_definition/$definition/
Maybe that's even causing the one test failure? :)
"for" vs. "of", should be consistent.
I think a brief comment explaining why this is zero would make sense. That wasn't possible with annotations, but now it is.
Wow, good catch. Any idea why this didn't trigger an exception or a fatal error?
Shouldn't we open an issue to ensure that it *will* trigger an exception/fatal error?
Comment #34
BerdirThat and similar fixes are in #2178795: Allow DiscoveryInterface::getDefinition() to throw an exception for an invalid plugin too I think, which are fixed there because otherwise tests are failing.
Comment #35
yched CreditAttribution: yched commented@Wim #33. 4 :
For the specific case of widgets / formatters, [Widget|Formatter]PluginManager::getInstance() specifically avoids failing when the requested plugin is unknown, and uses the 'default_widget' instead.
That behavior was introduced in CCK D6 to avoid white pages just because the module providing the wdget has been removed. Unlike the case of "the field type is missing", which is serious and we go great lengths to avoid, we try to consider "widget / formatter missing" as a non breaking condition.
I guess that could be reconsidered, but that's probably outside the scope of that issue.
Comment #36
Wim Leers#35: That helps. I forgot about that. Never mind then, let's not derail this :)
Comment #37
effulgentsia CreditAttribution: effulgentsia commentedWhy do we need a static settings() method and a nonstatic getDefaultSettings() method? Would it make more sense to just make getDefaultSettings() static and use that as our method name?
Comment #38
martin107 CreditAttribution: martin107 commentedPatch no longer applies.
Comment #39
BerdirRe-roll.
3. There is no reason, 0 is the default value for a pager ID and that's what we set.
Tried to address the other reviews, agreed that getDefaultMethods() seems unecessary, removed that and called static::settings() directly. defaultSettings() would be a better method but PhpStorm didn't want to rename it and I wanted to see how this goes before I go through it manually.
Comment #41
jessebeach CreditAttribution: jessebeach commentedRerolled. Rejected hunk in the interdiff.
Comment #43
andypostAnd new hunk after #2218199: Move email and number field types to \Drupal\Core\Field, remove modules
Comment #44
andypostComment #46
jessebeach CreditAttribution: jessebeach commented1 fail? Oh, we can totally get this green today! I'll race you andypost!
Comment #47
jessebeach CreditAttribution: jessebeach commentedSo are we not pulling settings out of annotation for fields? For instance
FieldItemBase
still has agetSettings
method that pulls settings from an annotation, such as withDecimalItem
.Here is the list of Classes that still have
settings
in annotations:Comment #48
longwaveI don't think the FieldType classes were ever attempted so far in this patch; in #28 swentel said they were working on this but since then #28 has only been repeatedly rerolled to keep up with HEAD. The Filter plugins are not relevant to this issue and ResponsiveImageFormatter looks like the only FieldFormatter that has been missed at present.
Comment #49
andypostTest
Drupal\field_ui\Tests\ManageDisplayTest
still broken because settings from display are "leaks" into pluginSo
hasSettings()
is true...This bug also re-producable in UI (change formatter for body field to 'Trimmed' and save display, then changing the formatter back to 'Default' will show a "wheel")
Comment #51
andypostI found
hasSettings()
useless because it's much easy to checkself::settings()
or$plugin->settings()
.Also this method does not guarantee that plugin settings are not merged as all above patches shows.
Not sure we need to convert field types here, maybe follow-up?
pushed
2136197-settings-annotations-remove-andypost
branchComment #52
jessebeach CreditAttribution: jessebeach commentedHere is the bleed andypost mentions in #49. I'm investigating where the bleed is coming from.
Comment #53
jessebeach CreditAttribution: jessebeach commentedThe patch in #51 passes the
ManageDisplayTest
, but it makes me nervous to just rip out a method that should work. Are we masking a deeper problem?Comment #54
jessebeach CreditAttribution: jessebeach commentedWhen the plugin instance is created in
DisplayOverviewBase
, the$display_options
for the plugin instance are polluted with the options from the previous display:$plugin = $this->getPlugin($field_definition, $display_options);
I'm looking at whether the logic in the
DisplayOverviewBase::buildFieldRow
has a bug.Comment #55
jessebeach CreditAttribution: jessebeach commentedThis looks really suspect.
Comment #56
andypostIt's not masking the problem, it's related to #2005434: Let 3rd party modules store extra configuration in EntityDisplay
Display holds settings from previous formatter, so probably the proper fix for that would be "proper merge"
Comment #57
andypostLet's see how this affects core, the test fixed too
Comment #58
jessebeach CreditAttribution: jessebeach commentedAwesome, #57 addresses the issue I raised in #54.
Comment #60
andypostFix broken test
Starting to convert field-type settings
Comment #62
andypost60: 2136197-settings-annotations-remove-andypost-60.patch queued for re-testing.
Comment #64
andypostwrong patch
Comment #66
andypostConverted instance settings to
instanceSettings
except content_translation module hack - module needs new storage for it's properties:Also attaching patch with conversion for widget and formatter only (*wf)
All pushed to
2136197-settings-annotations-remove-andypost
branchComment #68
tstoecklerMinor, but Annotations now support trailing commas, so that could be left alone.
Also minor but I actually liked the hasSettings() method. If we make it use $this->settings() instead of $this->settings it should work regardless of the display problem here, right?
Also, writing that, I wonder why we're going with settings() as method name instead of getSettings()?
Comment #69
BerdirBecause getSettings() already exists as an instance method. I think it should be defaultSettings(). We're apparently leaving out the get for static methods, see schema()/propertyDefinitions().
Comment #70
andypostFix 2 tests and cleanup #68.1
I do not see a reason in
hasSettings()
that calls static method and doing the sameAll left tests are cause by content translations except
EntityFieldTest
:there's some strange code
\Drupal\Core\TypedData\TypedDataManager::getPropertyInstance()
EDIT
getSettings()
is tricky - it merges defaults with field and instance level settingsComment #72
yched CreditAttribution: yched commentedCant look at code atm, but don't mix:
- the static method that defines the collection of settings and their default values for a given plugin class
- the accessors for the runtime settings values of a specific instantiated plugin (object). hasSetting() is in that area (although 5.4 syntax sugar makes it slghtly less needed)
(sorry if i'm just adding noise, i'm only following from afar)
Comment #73
andypostNext steps:
- clean-up config schema
- implement storage for content translation
- fix tests
Comment #74
andypostCurrently content translation module uses config storage for all it's definitions so probably better to add field properties (settings) translation to current one
content_translation_get|set_config()
wrappers seems worksComment #75
andypostI found the cause of
EntityFieldTest
failures - the settings is not plain associative array, it's values could be nested arrays.Suppose better to file new issue for that.
EDIT At least ER instance settings has
handler_settings
that value is arrayComment #76
andypostThe proper fix in this context, only content translation left here to fix
Comment #78
andypostlet's see how this removal affects tests
Comment #79
andypostFiled 2 follow-ups:
#2221577: Fix assumption that field settings is not a nested array
#2221559: Unify target_bundle vs target_bundles settings for entity reference fields
Comment #80
jessebeach CreditAttribution: jessebeach commentedDraft change notice for this issue: https://drupal.org/node/2221691
Comment #81
andypostPatch just needs some work to clean-up
git grep translation_sync
remains and reviews ;)Comment #82
jessebeach CreditAttribution: jessebeach commentedRegarding this change andypost noted: "I found that content translation stores its data in own yml"
I don't see how content translation in hooking into the settings of a FieldItem, so I'd like to get some input from folks working on multi-lingual about this change.
For instance in
content_translation_field_sync_widget
the following code is run:$translation_sync = $field->getSetting('translation_sync');
Because
translation_sync
is no longer set through the info alter, this key won't return a value.I think you might have uncovered a gap in the tests for translation syncing.
Comment #83
jessebeach CreditAttribution: jessebeach commentedSo, everything about the patch except for the content_translations looks good. Regarding content_translations, this is from the issue summary:
We can't leave this to a follow-up unfortunately, since it will introduce a regression.
Comment #84
andypostabout #82-83 - currently content translation duplicates its settings:
1) actual settings from
/admin/config/regional/content-language
are stored in\Drupal::config('content_translation.settings')
for each entity, bundle, field, field property2) the data from 1 is duplicated into
'translation_sync'
property of each configurable field and instancePatch #78 shows that we can remove the initialization of this setting but this still applies in
content_translation_save_settings()
:The only question here for me - if we remove this optimization in favor of relying on global config what is a performance impact?
Comment #85
jessebeach CreditAttribution: jessebeach commentedI really think the
translation_sync
tests have a gap in coverage. The field instance setting is being used to track whether a field is translatable.If I'm right, I should be able to write a test that fails under the conditions I surmise exist. Trying that.
Comment #86
jessebeach CreditAttribution: jessebeach commentedOk, I think I know what we need to do.
content_translation.module
has a functioncontent_translation_save_settings
. This function is called when the formlanguage_content_settings_form
at/admin/config/regional/content-language
is submitted.At this point, the settings for
translation_sync
are injected into each field instance in the bundles that have been enabled for translation.Using the Article image field as an example, this results in the
field.instance.node.article.field_image.yml
file being updated to includetranslation_sync settings
Rather than storing this
translation_sync
information in the field instance config, we need to save it in a config file that thecontent_translation
module controls and associate the configs to the corresponding field throughentity_type
,bundle
andfield_name
.The existing tests are still valid because we won't be altering the behavior of translation syncing.
Comment #87
jessebeach CreditAttribution: jessebeach commentedWe might be able to use
@FieldFormatter
plugins as an analogical model. If we create, let's say,@TranslationSync
plugins, we'd have to create a type per variation in fields. We'd probably be able to groupfield_types
in the@TranslationSync
plugins if the fields have similar translatable properties, for example, just a text field.I think this is the pattern we have in core to "extend" a field's settings and behavior.
Comment #88
yched CreditAttribution: yched commentedYou probably want to check with @plach, but I'm not sure why we'd need various sync plugins for various field types ?
Comment #89
andypostThere's a special issue for that #2143291: Clarify handling of field translatability
For the scope of the issue the removal of
content_translation_field_info_alter()
is enough, imo.Suppose only @plach can drop a light on c_t magic
Comment #90
BerdirI still think that public static settings() should be defaultSettings(), no? :)
Comment #91
andyposthm, probably...
but blocks plugins are using
defaultConfiguration()
so
defaultInstanceSettings()
vsdefaultInstanceConfiguration()
Comment #92
yched CreditAttribution: yched commented- re: "settings" / "configuration"
Yeah, a couple other plugin types use "configuration", some others use "options", the whole of Field API uses "settings" for its various plugin types.
That's unfortunate (I opened an issue like two years ago to try to unify this in advance, can't find it atm, but sadly it didn't go anywhere), but as I wrote in #8 above, "settings" is pretty well rooted in our APIs, and I don't think we want to rename it in this issue, and possibly not in D8 either.
Also, renaming "settings -> configuration" would be pretty confusing in our case, clashes with the "base fields / configurable fields" nomenclature.
*If* we rename/unify with something, "options" would be a better choice IMO. Yet again, not sure why it shouldn't be the other plugin types that unify to "settings" :-)
So yeah, for now +1 on defaultSettings()
- re: translation sync
Note that #2143291: Clarify handling of field translatability is about clarifying the flow of the 'translatable' property on fields / instances, and is not directly related to the translation_sync "setting" that is problematic here.
Comment #93
andypostrenamed all:
1)
settings()
->defaultSettings()
2)
instanceSettings()
->defauktInstanceSettings()
Comment #94
jessebeach CreditAttribution: jessebeach commentedThis is not quite accurate. The information stored in
content_translation.settings.yml
indicates whether a field is translatable, not its properties that should be synced.content_translations.settings.yml:
field.instance.node.article.field_image.yml
What might be duplicated is how the translation_sync settings get into a field instance settings file. This is why I'm still hesitant to rip out
content_translation_field_info_alter
as #78 did.Comment #95
andypostYes, so we still need some field&instance related storage for "extra" data like #2005434: Let 3rd party modules store extra configuration in EntityDisplay
1) Field item
propertyDefinitions()
could "mark" properties as translatable, as entity base fields doing.2) otoh this data is used only by
\Drupal\content_translation\FieldTranslationSynchronizer::synchronizeFields()
so could be easily moved to some other storage3) Let's think about contrib that wanna store some "own-extra-meta-data" on fields and instances
Comment #96
jessebeach CreditAttribution: jessebeach commentedI think you're spot-on andypost. There's going to be a beta-blocker followup to this issue. I think we can get this one closed with the code changes you've already written without regressions, but we won't be able to close this hole in this issue...it's just too big and the patch in this issue and already quite large.
Comment #97
yched CreditAttribution: yched commentedNote: The CMI guideline so far has always been "if you have 3rd party configuration to store about my config entities, store them yourself in your own config records, I'm not extending my config schema for you".
As explained in the issue summary over there, #2005434: Let 3rd party modules store extra configuration in EntityDisplay was opened because, for the specific case of formatters / widgets in EntityDisplays, it would be very painful for 3rd party code to store "extra settings about a formatter for a field in a $bundle / $view mode" themselves in a dedicated CMI record of their own: they would basically need to reproduce the "use Display for either $view_mode or 'default'" indirection logic encompassed in Entity(Form|View)Display::collectRenderDisplay() - which in most cases would probably end up badly implemented or simply overlooked.
"extra settings about a field / instance" do not have the same indirection constraint though, and it's fairly straightforward to store 3rd party settings about [entity_type].[field_name] or [entity_type].[bundle].[field_name] in a custom CMI record managed by the 3rd party. So providing a mechanism to "Let 3rd party modules store extra configuration in FieldConfig / FieldInstanceConfig" isn't as critical IMO.
This being said, IIRC (I'm still away from my coding env), the NodeType config entity does include a one-off mechanism to allow 3rd-party-added properties within the node.type.*.yml CMI records (presumably with some code to cleanup properties when the 3rd party module gets uninstalled ? didn't check, but that would be a bug if not). So if it was done for node types, maybe it could be considered for fields and instances as well...
Comment #98
andypostSuppose you mean User data that stored additions in "user.data" service (see
\Drupal\user\Entity\User::preSave()
)But
NodeType
has strictnode.settings.node
schema definition (at least menu stores own "menu.entity.node.$type" yml seemenu_parent_options()
)Comment #99
jessebeach CreditAttribution: jessebeach commentedAfter some more testing, I got to the bottom of my doubt. It turns out that
content_translation_field_info_alter
is invoked in order to add the settingtranslation_sync
to new fields on a node. Without this hook implementation, new fields don't get this setting. I took some screenshots that prove this.The problem is
hook_field_info_alter
is invoked during the process to collect a fields definitions, which no longer include settings, so the attempt incontent_translation_field_info_alter
to merge an array with an existing settings array lead to an undefined index error.What we need is a hook that gets invoked after definitions and settings have been merged but before the config entity is saved. In this case we can use
hook_entity_presave
.content_translation
already implements this hook to synchronize translatable fields before save. Now we ensure the settings are there as well. This does not resolve that we're still saving a third-party settings for a field in its config file, thus mucking with its schema. But this has always been the case. At least now we can (if the tests pass! I ran a couple locally that pass) move forward on this issue. This was the only reservation I had about it.Comment #100
jessebeach CreditAttribution: jessebeach commentedandypost, this suggestion by yched seems promising. It means we wouldn't have a schema associated with the field information. It would just be blob data, right?
Comment #101
andypost#99 looks good, I'd left removal of
translation_sync
to follow-up because it's not strictly in the scope of the patch.Seems @yched agree on that:
Anyway we need to clean-up schema files about field and instance settings for knows field types.EDIT no need to change schema that still needed to save config of the field and instance
Comment #102
plachAgain, sorry for not replying earlier, it's really hard for me to find time for core these days.
I think you guys properly addressed the issue so far (thanks @jessebeach for the thorough research work :) and the changes pertaining CT in the patch look reasonable to me.
Just one more thing about the removal of the CT keys from the various annotations: @yched's summary makes some convincing points about the need to do that, so I won't argue about this, but the reason those settings are attached to field annotations is that they are specific to every field-type. CT cannot automatically provide that information for every field-type contrib may provide, so if we want to remove them we need to introduce a new way for field-type-defining modules to integrate with CT and provide it the information it needs. I guess this is what @jessebeach was referring to in #87 with
@TranslationSync
plugins. Those might be overkill given the kind of information we need to provide, but at very least a basic_info()
hook would be needed.We may want to consider a generic field info hook: extending field annotations would be consistent with what we are already doing for entities: annotation + info() hook + info_alter() hook.
To be more clear:
Comment #103
andypostCT cannot automatically provide that information for every field-type contrib may provide
@plach Why? because of unpredictable field properties or "field_collumns"?
Comment #104
plachExactly :)
Actually, since CT has no need to special-case Field UI fields we could just leverage entity field info.
Comment #105
swentel CreditAttribution: swentel commentedHmm, this seems unrelated. It also should probably be defaultConfiguration()
We should also remove the 'Widget' settings from the annotation class - and add it to the change notice.
This looks sane to me so far. The question is whether it's allowed to open 2 new beta blocker issues ? :)
Comment #106
xjmDiscussed with @jessebeach and @swentel. Based on what @swentel described, I think it's definitely appropriate to split this issue into three parts to make it more reviewable and unblock other work, so @swentel is filing two followup parts for it as per #102.
Comment #107
jessebeach CreditAttribution: jessebeach commentedIt should be
defaultConfiguration
. This code here isn't fantastic, but it's what existed before this patch and this isn't the place to refactor it.Removed and the changed notice is updated to reflect this change.
Comment #108
swentel CreditAttribution: swentel commentedFollow ups filed:
(hopefully clear enough titles)
Comment #109
yched CreditAttribution: yched commentedc_t adding extra stuff to field type plugin definitions to provide metadata about how a specific field type can leverage "translation sync" sounds perfectly reasonable to me, that's what hook_field_info_alter() is here for ?
Comment #110
swentel CreditAttribution: swentel commentedOk, let's do this then ?
Comment #111
andypostRe-roll after #2191709: Remove the "configurable" flag on field types (pushed to sandbox)
Also, we can't use
hook_field_info_alter()
before #2221577: Fix assumption that field settings is not a nested array so #99content_translation_entity_presave()
is nice workaroundComment #112
yched CreditAttribution: yched commentedSince this really is an ugly WTF, let's please add a @todo comment pointing at #2224761: Add a generic way to add third party configuration on configuration entities and implement for field configuration :-)
Comment #113
andypost@todo added
Comment #114
yched CreditAttribution: yched commentedActually reviewed the patch - mostly minor remarks, other than that this looks good to go.
Thanks folks !
I would tend to have core encourage a more readable array syntax like:
, but maybe it's only me :-)
Why this change ? Looks unrelated and with potentially nasty side effects ?
Not sure why this change either, but at any rate we should avoid calling/computing static::defaultSettings() twice in a single line :-)
Nice catch, but since then we have moved to just "@return $this" ?
Grammar looks off in the comment.
"The target bundle is handled by the 'target_bundles' property in the 'handler_settings' instance setting." ?
Actually we should just call FieldTypePluginManager::getDefaultSettings() here ?
(that's what FieldInstanceConfig::preSave() does already when merging default instance settings)
Same here, call FTPM::getDefaultSettings() / getDefaultInstanceSettings() ?
Comment is now off, there are no "consecutive calls to array_key_exists" anymore.
--> change to "We assume that one call to array_key_exists() is more efficient than ...." ?
No need to fetch $field_type, just use 'plugin.manager.field.field_type'::getDefaultSettings() ?
same
same
same
Again, IMO ideally only the plugin manager would call the static methods on the plugin class, the rest of the code would call the methods on the plugin manager, which are the "official API" to get the default settings of a plugin.
That's the standard pattern we have for other static definition methods (field properties, field schema...). They are collected by one method somewhere (typically on a manager), and the rest of the code goes through that method.
Nitpick, but extracting the formatter plugin manager to a separate var moight be more readable.
Nice :-)
Comment #115
yched CreditAttribution: yched commentedAlso, re @andypost #111:
No, I did mean node.settings, not User data :-)
Notice that node.settings is keyed by module name, thus allowing 3rd party modules to add stuff in there and still provide a config schema.
Comment #116
swentel CreditAttribution: swentel commentedNew patch, addressed all. Some comments
1. Well, that would be massive change for this patch. Don't have a strong opinion, but I'd rather do that in follow up if you feel strongly about it ;)
3. Looks weird indeed, reverted it, we'll see if this still turns back green.
4. I did a quick check and to me this seems fine, unless I'm missing something
Comment #118
andypost4) fixed, @swentel see https://drupal.org/node/1354#types
Also merge after #2169983: Move type-specific logic from ListItemBase to the appropriate subclass
Will try to fix 1) if green
Comment #119
jessebeach CreditAttribution: jessebeach commentedI've got #1 fixed already. Merging in....
Comment #120
swentel CreditAttribution: swentel commentedWe should just remove this line
Comment #121
jessebeach CreditAttribution: jessebeach commentedRefactored the settings functions' bodies to return an array of settings with the defaults merged in, as per #1 in #114.
Also removed the line mentioned by swentel in #120.
Comment #122
jessebeach CreditAttribution: jessebeach commentedAnnnnnd, now the line mentioned in #120 is removed.
Comment #123
swentel CreditAttribution: swentel commentedoops
Otherwise looking great.
@yched, I'll let you pull the trigger on this.
Comment #125
jessebeach CreditAttribution: jessebeach commentedandypost found an unconverted settings annotation in
ListBooleanItem
. I've refactored it to thearray() + defaults()
format suggested in #114/#1.Comment #128
yched CreditAttribution: yched commentedw00t ! Thanks !
RTBC if green :-)
Comment #130
swentel CreditAttribution: swentel commentedA rejection file slipped in. Still RTBC though ! :)
Comment #131
alexpottCommitted 7f61620 and pushed to 8.x. Thanks!
Comment #133
andypostOne more place found
Comment #134
swentel CreditAttribution: swentel commentedAh right, good catch.
Comment #135
alexpottCommitted 4c109a5 and pushed to 8.x. Thanks!
Comment #137
andypostComment #138
yched CreditAttribution: yched commentedAdjusted the change notice (https://drupal.org/node/2221691) a bit,
and updated the existing change notices about "(field types | formatters | widgets) as plugins" :
https://drupal.org/node/2064123
https://drupal.org/node/1805846
https://drupal.org/node/1796000