Problem/Motivation

We had two bugs in a project, a fatal error on a behavior because \Drupal\paragraphs\ParagraphsBehaviorBase::getFieldNameOptions() returned a base field and the summary showing the username despite that being a base field.

After a bit of debugging, the problem turned out to be that the uid field had a base field override. Combined with the problem that we checked the wrong FieldConfigInterface (the one in Drupal\Core covers both configurable fields and base field overrides) and in the other case checked for BaseFieldDefinition which was then not true anymore.

Proposed resolution

Use Drupal\field\FieldInterface in both cases.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review
FileSize
2.05 KB
johnchque’s picture

Assigned: Unassigned » johnchque

Will add tests for this.

johnchque’s picture

The last submitted patch, 4: paragraphs-fieldconfiginterface-2946102-4-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 4: paragraphs-fieldconfiginterface-2946102-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnchque’s picture

The last submitted patch, 7: paragraphs-fieldconfiginterface-2946102-7-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Berdir’s picture

Status: Needs review » Needs work
+++ b/tests/modules/paragraphs_test/src/Plugin/paragraphs/Behavior/TestFieldsSelectionBehavior.php
@@ -22,6 +22,12 @@ class TestFieldsSelectionBehavior extends ParagraphsBehaviorBase {
    */
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
+    if ($form_state->getFormObject()->getEntity()->id()) {
+      $paragraphs_type = $form_state->getFormObject()->getEntity();
+      $field_definition = \Drupal::service('entity_field.manager')->getFieldDefinitions('paragraph', $paragraphs_type->id())['uid'];
+      $field_definition->getConfig($paragraphs_type->id())->save();
+    }

You should do this in the test class, not in the test plugin.

johnchque’s picture

The last submitted patch, 10: paragraphs-fieldconfiginterface-2946102-10-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

The last submitted patch, 10: paragraphs-fieldconfiginterface-2946102-10-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good I think.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Fixed

:-) Committed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.