Skip to content

[Magento 2.3.x] Declarative Schema :: Data/Schema Patches getAliases() not working as expected #23031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
atishgoswami opened this issue May 28, 2019 · 8 comments · May be fixed by #38239
Closed
Assignees
Labels
Component: Framework/Setup USE ONLY for FRAMEWORK RELATED BUG! E.g If bug occurs during Catalog Setup use just Catalog Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@atishgoswami
Copy link
Contributor

Preconditions

Project Environment

Magento Version: 2.3.x CE
PHP: 7.2
Database: MySQL 5.7
OS: CentOS 7
Caching: Varnish Cache and OPcache

Steps to reproduce

  1. Create a schema patch with a class name e.g. ExampleSchemaPatch
  2. Add a logger inside the apply method for the schema patch class to indicate that the apply method was executed
  3. Run setup:upgrade
  4. Check the patch_list table a fully qualified class name for the patch class would be present
  5. Check the log file to confirm that the apply method for the patch was executed
  6. Now change the class name of the applied patch to some something else e.g. ChangedExampleSchemaPatch
  7. Added the old class name as an array item for the return array for the getAliases() method
public function getAliases()
{
    return [
        ExampleSchemaPatch::class
    ];
}
  1. Run setup upgrade one more time

Actual Result

  1. The patch gets reapplied. This can be verified by checking the log file
  2. A new entry of the renamed patch is added to the patch_list table

Expected Result

The patch should not be reapplied.

Note: This issue can be replicated for Data as well as schema patches

@m2-assistant
Copy link

m2-assistant bot commented May 28, 2019

Hi @atishgoswami. 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.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@atishgoswami do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label May 28, 2019
@atishgoswami atishgoswami changed the title [Magento 2.3.x] Declarative Schema Patches getAlias() not working as expected [Magento 2.3.x] Declarative Schema Patches getAliases() not working as expected May 28, 2019
@atishgoswami atishgoswami changed the title [Magento 2.3.x] Declarative Schema Patches getAliases() not working as expected [Magento 2.3.x] Declarative Schema :: Data/Schema Patches getAliases() not working as expected May 28, 2019
@sdzhepa sdzhepa added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Oct 4, 2019
@korostii korostii self-assigned this Oct 23, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 23, 2019

Hi @korostii. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: 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.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!


@korostii korostii added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 24, 2019
@ghost ghost removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Oct 24, 2019
@ghost
Copy link

ghost commented Oct 24, 2019

✅ Confirmed by @korostii
Thank you for verifying the issue! 👍 Your confirmation will help us to acknowledge and process this report.

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Oct 24, 2019

@korostii Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

  • Add "Component: " label(s) to this ticket based on verification result. If uncertain, you may follow the best guess
  • Add "Reproduced on " label(s) to this ticket based on verification result

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@korostii korostii added Component: Framework/Setup USE ONLY for FRAMEWORK RELATED BUG! E.g If bug occurs during Catalog Setup use just Catalog Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Oct 24, 2019
@ghost ghost removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Oct 24, 2019
@korostii korostii self-assigned this Oct 24, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 24, 2019

Hi @korostii. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: 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.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!


magento-engcom-team added a commit that referenced this issue Oct 26, 2019
 - Merge Pull Request #25265 from korostii/magento2:korostii-patch-23031
 - Merged commits:
   1. d135cb1
@francescosalvi
Copy link

Maybe I am dumb or have missed the point of the issue, but how does the change in https://github.com/magento/magento2/pull/25265/files solve this issue exactly?

I see that the current patch is applied first (line :162) and only then getAliases() is invoked and its result iterated... shouldn't it be the other way around? (i.e.: get aliases, if some is already listed in history, skip apply of current patch)

In fact, by testing empirically, all I get from adding the old class/patch name among aliases, is that the migration breaks when it reaches the current patch.. but only after having applied it!

Therefore I think documentation snippet at https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/data-patches.html

This internal Magento method, that means that some patches with time can change their names,
but changing name should not affect installation process, that's why if we will change name of the patch
we will add alias here

is misleading

@PauloPhagula
Copy link

@francescosalvi I'm no expert either, but I'd say you're at least half-right.

The patch does not get applied twice only due to the rollback called within the catch clause.

While the actual behavior does not match what is written on the docs, I think the intended behavior is the one described.

The incorrect behavior I see (in my case) is that the application of the new patch fails while referencing the first one (an alias). But according to that doc snippet there should be no exception thrown, but simple skipping of reapplying the patch.

Screenshot from 2020-12-22 15-43-49

@magento-engcom-team could you reopen and have a second look at this issue?

@PauloPhagula
Copy link

Opened a new issue #31396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Framework/Setup USE ONLY for FRAMEWORK RELATED BUG! E.g If bug occurs during Catalog Setup use just Catalog Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants