magento2
magento2 copied to clipboard
migrateDataFromAnotherTable() does not work for declarative schema
Preconditions
- Magneto Community Edition 2.4.3-p1
Steps to reproduce
- Create a table using a declarative schema
- run setup:upgrade
- Add rows to the created table
- Rename the table using migrateDataFromAnotherTable() in the declarative schema
- run setup:upgrade again
Expected result
- Table with a new name has been created
- Data from the table with the previous name is copied to the table with the new name
Actual result
- Table with a new name has been created
- Data is not copied to the new table
Additional Info
During the investigation, it was found that the vertexinc/module-tax module was installed together with Magneto.
This module adds its own trigger to create a table in a declarative schema
When you breakpoint in the Magento\Framework\Setup\Declaration\Schema\Operations\CreateTable class, you can see that the trigger added in app/etc/di.xml is missing from the list of added ones, and there is only vertexinc present there
After vertexinc was commented out
and the setup:upgrade started again, vertexinc disappeared and migrateDataFromAnotherTable appeared
After the setup:upgrade was completed, the rows were copied to the new table.
Most likely the reason lies somewhere in the merger app/etc/di.xml and others di.xml files, in our case it is vendor/vertexinc/module-tax/etc/di.xml
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [ ] 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”.
Hi @DmitryFurs. Thank you for your report. To help us process this issue please make sure that you provided the following information:
- Summary of the issue
- Information on your environment
- Steps to reproduce
- Expected and actual results
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue: @magento I am working on this
- Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
@magento/ext-vertex please take a look at this issue.
Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself. -
[ ] 3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
[ ] 5. Add label
Issue: Confirmed
once verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
This is the exact same issue I've described here
https://github.com/magento/magento2/issues/26433
However, my issue got zero attention for over a year so I've closed it.
Basically adding new arguments to types via di.xml
overwrites the entire node.
Hard to say it is desired or a bug, but it is safe to assume the XMLs are merged, as the rest of them (config.xml, cache.xml, routes.xml and so on) are in fact merged.
Imho, it is a bug, but you can see the info about this in devdocs:
https://devdocs.magento.com/guides/v2.4/extension-dev-guide/build/di-xml-file.html
@maghamed @kandy, can you explain, why it was implemented in this way? is it a bug, or a feature?
It was a feature when some one implemented his mind. But currently fix for one bug add two new bugs in different places 🤔
@ihor-sviziev
Array items of DI configuration in the scope of the same area should be merged.
It's a pretty important functionality for modularity and is used in multiple places, For example, \Magento\Framework\Console\CommandListInterface
has ~ 30 places in different modules that add items in the common array argument.
I try to reproduce this issue and I do finely after some tries. So the issue can be reproduced only if DI compilation was not run, and only if the configuration is defined in a prime file (app/etc/env.php)
also please see https://github.com/magento/magento2/issues/3835#issuecomment-198473455
I prepared draft PR https://github.com/magento/magento2/pull/34457 that probably can fix this issue
@kandy Will this also resolve the issue with invalid merging of Product Type configuration?
For example when you want to change the flag refundable
for virtual
product type in product_types.xml
@lbajsarowicz no, I think it unrelated issues
Faced similar issue in DI when wanted to add new items in different area https://github.com/magento/magento2/issues/34464
Is there any news here? Thanks!
Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself. -
[ ] 3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
[ ] 5. Add label
Issue: Confirmed
once verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @DmitryFurs,
We have tried to reproduce this issue in 2.4-develop but for us, it is not reproducible.
We have followed below steps
1.Created catalogproducts table using a declarative schema
2.Added rows to the catalogproducts table.
3.Rename the table using migrateDataFromAnotherTable() as catalogproducts1
- Table with new name is created and the data are copied to renamed table.
Please let us know if we are missing any steps here.
Thanks.
@engcom-Delta The removal of VBEs resolved the symptom of the issue.
The real issue is the way di.xml is merged between the global app/etc/di.xml and module di.xmls (with module di.xml's replacing, instead of expanding, entries in app/etc/di.xml).
When this issue was created, Vertex added a schema trigger. Any module that does so will overwrite core schema triggers - which is not desirable.
@engcom-Delta Yes, @navarr is right, the problem is that you can't add your own triggers. When merging from different areas, native triggers will be overridden, even if they have other unique names.
@DmitryFurs ,@navarr
We have tried to reproduce this issue in magento 2.4-develop still this issue is not reproducible with merging of di.xml files. In below document vertex is not bundled extension in latest versions.
https://docs.magento.com/user-guide/tax/taxes.html
Please let us know if we are missed anything.
Thanks.
@engcom-Delta What should we do if we need to install the vertex module or any other that adds its own triggers? If this module is installed, the problem will reappear. How to fix the situation?
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself. -
[ ] 3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
[ ] 5. Add label
Issue: Confirmed
once verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @DmitryFurs @navarr,
We have tried to reproduce this issue in the Magento 2.4-develop as well as 2.4.5 by creating a custom module to create a table. We have followed the below steps with and without the Vertex module installed:
- Creating a module to create a table.
- Run
bin/magento setup:db-declaration:generate-whitelist --module-name=Magz_Issue34394
command - and then
bin/magento s:up
With the Vertex module, we have the new table created but no data copied from the existing table but without that module the data is also copied.
We need to fix the way in which di.xml merges. So the issue seems in the Magento module. Hence confirming the issue.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6950 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Hello @DmitryFurs @navarr,
We have discussed this issue with developers internally and come to the below conclusion:
As per the analysis for the issue, the vertexinc/vertex-tax-module:4.2.8
di.xml
is an area-specific configuration, and the app/etc/di.xml is the initial one. As per devdocs the area-specific config will override the initial one so this is expected behavior. we can check further Here.
We have one different example as well to demonstrate the expected behavior of DI.
vendor/magento/module-customer/etc/di.xml
app/etc/di.xml
The module-specific configuration will override the same expected behavior.
Thanks
@engcom-Hotel I think everyone in this thread understands that's the expected behavior of XML merge as it exists today
However, I think the point of the ticket is that database triggers especially should not be disappear if a module tries to add one
This has two potential solutions to that regard:
- Merge initial and area configuration instead of overwriting
- Or Magento needs to host important configuration in an area configuration file
Personally, I've never understood why app/etc/di.xml exists or is treated differently.
@engcom-Hotel I completely agree with @navarr
Hello @navarr @DmitryFurs,
We are under discussion on this issue internally. Will keep you posted on this soon.
Thanks
Moving this ticket "On hold"
@engcom-Hotel @engcom-Echo any updates? Why task was closed w/o any comments?
Hi @ihor-sviziev @DmitryFurs,
As per the Internal team they are not able to reproduce the issue hence they have closed jira form their side.
Thanks.
Were there any changes made to the way di.xml entries are loaded, or did internal just give up on fixing this architectural issue?