magento / magento/data-migration-tool

magento/module-catalog/Setup/Patch/Data/UpdateMultiselectAttributesBackendTypes.php breaks upgrade in migrated sites from 1.x

Open
#919 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
339
Forks
195
PR merge metrics
No merged PRs in 30d

Description

### Preconditions and environment

- 2.4.6-p2

### Steps to reproduce

To replicate this you need

1. Magento 2 (e.g. 2.4.1) that was migrated from 1.x and the 1.x instance had multiselect attributes with data (stored in _text table)
2. Use data migration tool to transfer the data which will copy the values from _text table to _varchar table during migration
3. Upgrade to 2.4.6-p2

The system will try to copy data from the _varchar table back to the _text table which was already migrated with the data migration tool to _text and to _varchar table. In the process you'll get this error about duplicate values

### Expected result

Upgrade occurs properly

### Actual result

Duplicated values throw exceptions

![image](https://github.com/magento/magento2/assets/20220341/ad3735b5-4401-49a6-a421-b65f612a4da9)

### Additional information

There is only one real solution here, the patch needs to first clear the invalid data from _text table before migrating from _varchar to _text

e.g.

```sql
delete from catalog_product_entity_text where catalog_product_entity_text.attribute_id in (select eav_attribute.attribute_id from eav_attribute where eav_attribute.backend_type = 'varchar' and eav_attribute.entity_type_id = 4)
```

### Release note

_No response_

### Triage and priority

- [ ] Severity: **S0** _- Affects critical data or functionality and leaves users without workaround._
- [X] Severity: **S1** _- Affects critical data or functionality and forces users to employ a workaround._
- [ ] Severity: **S2** _- Affects non-critical data or functionality and forces users to employ a workaround._
- [ ] Severity: **S3** _- Affects non-critical data or functionality and does not force users to employ a workaround._
- [ ] Severity: **S4** _- Affects aesthetics, professional look and feel, “quality” or “usability”._

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with magento/module-catalog/Setup/Patch/Data/UpdateMultiselectAttributesBackendTypes.php and reproduce the upgrade on a migrated Magento 1.x site containing multiselect attribute data. Inspect the catalog_product_entity_text and catalog_product_entity_varchar records involved, then verify that the upgrade completes without duplicate-value exceptions and preserves the migrated data.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.