Problem/Motivation
Creating an entity reference to a Commerce License product variation causes a Warning: Undefined array key "base_plugin_label":
Warning: Undefined array key "base_plugin_label" in Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem->fieldSettingsForm() (line 464 of core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php).
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem->fieldSettingsForm(Array, Object) (Line: 126)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
Drupal 10 + Commerce License 3.0.0 + Entity Reference to a Commerce License Product Variation
Proposed resolution
The issue seems to be that Drupal\commerce_license\Plugin\EntityReferenceSelection\ProductVariationSelection defines an @EntityReferenceSelection with a colon in the ID (commerce_license:commerce_product_variation) but doesn't define a derivative (I'm basing this deduction off a similar issue:
https://www.drupal.org/project/dynamic_entity_reference/issues/3274925 →
).
We could just add the default deriver to the @EntityReferenceSelection definition (as per Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection)? e.g.
/* @EntityReferenceSelection(
* id = "commerce_license:commerce_product_variation",
* label = @Translation("Commerce license product variation selection"),
* entity_types = {"commerce_product_variation"},
* group = "commerce_license",
* weight = 5,
* deriver = "Drupal\Core\Entity\Plugin\Derivative\DefaultSelectionDeriver"
* )
*/
Remaining tasks
If this sounds like a suitable fix I can provide a patch.