Problem/Motivation
While working on #3574548: Unexpected properties in ComponentSource data, we noticed some unexpected node_id and third_party_settings values (always empty, of course, they don't make sense here) added to ComponentSource data:
node_id: 699714c9b5736
source_id: component
source:
component:
component_id: 'ui_suite_daisyui:avatar'
variant_id: {}
props: {}
slots: {}
third_party_settings: ''
node_id: ''They may come from ComponentForm:
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
if ($input) {
$value = [
'component_id' => $input['component_id'] ?? NULL,
'variant_id' => $input['variant_id'] ?? NULL,
'props' => $input['props'] ?? [],
'slots' => $input['slots'] ?? [],
'third_party_settings' => $input['third_party_settings'] ?? NULL,
'node_id' => $input['node_id'] ?? NULL,
];
$element['#default_value'] = $value;
return $value;
}
else {
return [
'component_id' => NULL,
'variant_id' => NULL,
'props' => [],
'slots' => [],
'third_party_settings' => NULL,
'node_id' => NULL,
];
}
}Introduced in #3551360: Add third party settings and tree Node ID in field storage.
Proposal
A naive solution would be to move third_party_settings and node_id at the same level than source_id and source for SDC components:
node_id: 699714c9b5736
source_id: component
source:
component:
component_id: 'ui_suite_daisyui:avatar'
variant_id: {}
props: {}
slots: {}
third_party_settings: {]But those properties are expected there for any source plugin targeting slots (BlockSource, WysiwygSource...), so it may be better to manage it in a more generic way. I am not opposing to implement it for all sources, even the ones not targeting slots, if it is the cleanest way to do it, because we never know, it may be useful later.
Issue fork ui_patterns-3574820
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pdureau commentedAssigned to Christian because it is the follow-up of #3551360: Add third party settings and tree Node ID in field storage
Comment #3
herved commentedI noticed the same issue #3551360-17: Add third party settings and tree Node ID in field storage
I think the implemented solution is not optimal as these are producing config schema errors and node_id seems specific to nodes, displays can be used on many other entity types.
Comment #5
pdureau commented@herved:
Indeed
"Node" in "node_id" is a tree node of the display buildable data, it is not related to Drupal Node content entity.
See: https://en.wikipedia.org/wiki/Tree_(abstract_data_type) : "represents a hierarchical tree structure with a set of connected nodes"
--------
@christian.wiedemann: MR opened and commit pushed. Drupal CI is not working today (in purpose, they stopped it), so i am not moving to "in review" status right now.
We have also talked about adding Node IDs also in (nested) props source (today, Node IDs are only added to slot sources). Do you want to do this in the scope of this ticket?
Comment #6
grimreaperHello,
MR is ok for me.
Needs to retrigger the pipeline when wanting to merge after Core security release of this evening.
Comment #7
herved commentedMakes sense, sorry I didn't read the code and just assumed, seeing those exported in config was just confusing to me and I thought it was about node entities. Maybe tree_node_id would have been clearer.
Comment #8
grimreaperThinking about this issue, I don't think an update hook is needed to clean existing config of those properties, but in case I just wanted to mention it to think about it.