setFieldMapperId should reset fieldMapperPlugin member

Created on 4 March 2024, 10 months ago

Problem/Motivation

In ExternalEntityType class, the public method setFieldMapperId() (currently only used in tests in this module) changes the field mapper plugin id while it does not reset the fieldMapperPlugin member which may have been initialized with a different field mapper id:

  /**
   * {@inheritdoc}
   */
  public function setFieldMapperId($field_mapper_id) {
    $this->field_mapper_id = $field_mapper_id;
  }

Therefore, a developer may think calling setFieldMapperId() changes the field mapper but it does not and there can be a discrepancy between what is returned by ->getFieldMapperId() and ->getFieldMapper()->getPluginId() which could lead to unexpected behaviors. As well, the field mapper config is not changed and may not correspond to the field mapper.

Proposed resolution

  /**
   * {@inheritdoc}
   */
  public function setFieldMapperId($field_mapper_id) {
    $this->field_mapper_id = $field_mapper_id;
    $this->fieldMapperPlugin = NULL;
    $this->field_mapper_config = [];
  }

Remaining tasks

Review the logic and merge.

User interface changes

None.

API changes

None.

Data model changes

None.

Note: I'll prepare a PR.

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇫🇷France guignonv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024