Postponing as it's not 100% clear we need to do this yet, but the info is best documented as an issue.
Overview
surfaced in
✨
Displaying and creating folders
Active
in ComponentValidationTest
the setup includes a call to
$this->entity = Component::create([
'id' => 'sdc.xb_test_sdc.my-cta',
'category' => 'Test',
'source' => SingleDirectoryComponent::SOURCE_PLUGIN_ID,
'source_local_id' => 'xb_test_sdc:my-cta',
'active_version' => 'b4cd62533ff9bd99',
'versioned_properties' => [
VersionedConfigEntityBase::ACTIVE_VERSION => [
'settings' => [
'prop_field_definitions' => [
'text' => [
// @see \Drupal\Core\Field\Plugin\Field\FieldType\StringItem
'field_type' => 'string',
// @see \Drupal\Core\Field\Plugin\Field\FieldWidget\StringTextfieldWidget
'field_widget' => 'string_textfield',
'default_value' => [0 => ['value' => 'Hello, world!']],
'expression' => 'ℹ︎string␟value',
],
'href' => [
// @see \Drupal\Core\Field\Plugin\Field\FieldType\UriItem
'field_type' => 'uri',
// @see \Drupal\Core\Field\Plugin\Field\FieldWidget\UriWidget
'field_widget' => 'uri',
'default_value' => [0 => ['value' => 'https://drupal.org']],
'expression' => 'ℹ︎uri␟value',
],
'target' => [
// @see \Drupal\options\Plugin\Field\FieldType\ListStringItem
'field_type' => 'list_string',
'field_storage_settings' => [
'allowed_values_function' => 'experience_builder_load_allowed_values_for_component_prop',
],
// @see \Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsSelectWidget
'field_widget' => 'options_select',
'default_value' => NULL,
'expression' => 'ℹ︎list_string␟value',
],
],
],
],
],
'label' => 'Test',
]);
$this->entity->save();
Even if it's confirmed this component does NOT exist, the call to $this->entity->save();
will result in a 'It is impossible for an item to exist in multiple Folders.'
RuntimeException.
In that MR's Component.php, there's logic in the postSave
method that only runs when $update
is FALSE, yet it appears to be running multiple times as the component it is currently creating is identified as already belonging to a folder. If subsequent calls had $update
as TRUE
there would likely be no issue.
It's possible there's another reason for the problem, but the multiple postSave() calls is what the troubleshooting hints most strongly at. It's not clear if this is an issue of how the component is created in that test, or if it's a broader issue that could impact IRL situations as well.
Proposed resolution
User interface changes