magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Fix Patch aliases usage (issue #31396)

Open thomas-kl1 opened this issue 2 years ago • 19 comments

Description (*)

Currently the aliases are useless and have no meaningful usage in codebase.

See documentation: https://developer.adobe.com/commerce/php/development/components/declarative-schema/patches/

public function getAliases() { /** * This internal 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 */ return [];

Related Pull Requests

  • https://github.com/magento/magento2/pull/37682

Fixed Issues (if relevant)

  1. Fixes magento/magento2#31396
  2. Fixes magento/magento2#23031

Manual testing scenarios (*)

  1. Add a patch with aliases

  2. None of the aliases must exists in db

  3. Run setup:upgrade

  4. The patch and its aliases are added to patch_list table

  5. Add a patch with aliases

  6. Any of its aliases must exists in db

  7. Run setup:upgrade

  8. The patch is not ran because it's already applied previously by one of its aliases

Questions or comments

I did not edit the \Magento\Framework\Setup\Patch\PatchHistory::isApplied for BC purpose. However it would have been better to have this method updated to get a PatchInterface as an argument and check for its aliases there.

Contribution checklist (*)

  • [x] Pull request has a meaningful description of its purpose
  • [x] All commits are accompanied by meaningful commit messages
  • [x] All new or changed code is covered with unit/integration tests (if applicable)
  • [x] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • [x] All automated tests passed successfully (all builds are green)

thomas-kl1 avatar Dec 01 '23 14:12 thomas-kl1

Hi @thomas-kl1. Thank you for your contribution! Here are some useful tips on how you can test your changes using Magento test environment.

Add the comment under your pull request to deploy test or vanilla Magento instance:
  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

:exclamation: Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s) For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here :information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation. Join Magento Community Engineering Slack and ask your questions in #github channel.

m2-assistant[bot] avatar Dec 01 '23 14:12 m2-assistant[bot]

@magento run all tests

thomas-kl1 avatar Dec 01 '23 14:12 thomas-kl1

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@magento run all tests

thomas-kl1 avatar Dec 01 '23 17:12 thomas-kl1

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@magento run all tests

thomas-kl1 avatar Dec 01 '23 19:12 thomas-kl1

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@magento run all tests

thomas-kl1 avatar Dec 06 '23 13:12 thomas-kl1

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

Functional tests failures are not related to the PR. Unit test must be updated accordingly.

thomas-kl1 avatar Dec 06 '23 20:12 thomas-kl1

@magento run all tests

thomas-kl1 avatar Dec 06 '23 20:12 thomas-kl1

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@magento run all tests

thomas-kl1 avatar Dec 06 '23 23:12 thomas-kl1

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@magento run all tests

thomas-kl1 avatar Jan 18 '24 13:01 thomas-kl1

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues.

@magento run all tests

thomas-kl1 avatar Apr 09 '24 08:04 thomas-kl1

@magento run all tests

thomas-kl1 avatar Apr 26 '24 10:04 thomas-kl1

@magento run all tests

thomas-kl1 avatar May 06 '25 12:05 thomas-kl1

@engcom-Hotel I've updated this PR description and removed the reference.

thomas-kl1 avatar Jun 30 '25 11:06 thomas-kl1

@magento run all tests

engcom-Hotel avatar Jul 01 '25 02:07 engcom-Hotel

@engcom-Hotel

Regarding static test failures, it's related to the copyright header change, I'll check, could you give the new copyright to apply please? https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/38239/079f4563d120ab5795fb65006c654d26/Statics/console-error-logs.html

Units tests failure are not related to this PR and seems related to RMA changes (not in scope of this PR): https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/38239/5da9f12d3970de433b743d636689530d/Unit/console-error-logs.html

Webapi tests, I dont see how it's related to this PR change 🤔

Functional tests, I dont see how it's related to this PR change 🤔

thomas-kl1 avatar Jul 01 '25 08:07 thomas-kl1

@magento run all tests

thomas-kl1 avatar Jul 01 '25 20:07 thomas-kl1

Hi @thomas-kl1,

Thank you for your contribution!

I have followed below steps in order to reproduce the test the PR.

:heavy_check_mark: QA Passed

Before PR :heavy_multiplication_x: 

  1. Create a patch called 'ExampleDataPatch' with no aliases
class ExampleDataPatch implements DataPatchInterface
{
    /**
     * @var ModuleDataSetupInterface
     */
    private $moduleDataSetup;


    /**
     * @var LoggerInterface
     */
    private $logger;

    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        LoggerInterface $logger
    ) {
        $this->moduleDataSetup = $moduleDataSetup;
        $this->logger = $logger;
    }
    
    public function apply()
    {
        $this->moduleDataSetup->startSetup();
        $this->logger->info('ExampleSchemaPatch: Apply method executed.');
        $this->moduleDataSetup->endSetup();
    }
    
    public static function getDependencies()
    {
        return [];
    }
    
    public function getAliases()
    {
        return [];
    }
}
  1. Run bin/magento setup:upgrade, patch ExampleDataPatch gets applied and 'ExampleDataPatch' is added to the patch_list table
  2. Rename patch ExampleDataPatch file and class name to 'ChangedExampleDataPatch'
  3. Add 'ExampleDataPatch' to the aliases
public function getAliases()
    {
        return [
            ExampleDataPatch::Class
        ];
    }
  1. Run bin/magento setup:upgrade again, patch ExampleDataPatch gets applied again verified it from log file and 'ChangedExampleDataPatch' is added to the patch_list table image image

After PR Changes :heavy_check_mark:

  1. Followed step 1-6 as above
  2. Run bin/magento setup:upgrade again, patch ExampleDataPatch didn't get applied again verified from log file and ChangedExampleDataPatch is getting added to the patch_list table. image image

As the build is failing, moving this PR to Extended Testing.

engcom-Charlie avatar Jul 07 '25 11:07 engcom-Charlie

@magento run all tests

engcom-Charlie avatar Jul 07 '25 11:07 engcom-Charlie

@magento run Functional Tests B2B, Functional Tests EE

engcom-Charlie avatar Jul 08 '25 04:07 engcom-Charlie

@engcom-Charlie the integration tests failures are not related to these changes.

thomas-kl1 avatar Jul 08 '25 08:07 thomas-kl1

@magento run all tests

engcom-Charlie avatar Jul 09 '25 05:07 engcom-Charlie

@magento run Functional Tests B2B, Functional Tests CE, Unit Tests

engcom-Charlie avatar Jul 10 '25 04:07 engcom-Charlie

The Functional B2B in recent 2 builds have one common failure and its a known issue. The rest are neither part of PR nor affected by PR changes.

Run 1: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/38239/965d2598a51e2d0368da7fff85e5e50e/Functional/allure-report-b2b/index.html#categories

image

Run 2: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/38239/b68be97fd9a9ffd4638e21cddcf4f033/Functional/allure-report-b2b/index.html#categories/2fc037f47773dd7551f2e766bbf34efa/9a053d1c29d42d2b/

image

Known Issue: ACQE-8287: StorefrontProductNoLongerVisibleInWishlistOnceUserUnassignedFromCompanyTest

The Functional CE failures are not consistent in recent 2 builds. The rest are neither part of PR nor affected by PR changes, seems to be flaky. Hence moving this PR to Merge in Progress.

Run 1: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/38239/800b0099885f5877ec1d695c6f0fb73f/Functional/allure-report-ce/index.html#categories/1a0b192d5a64d4dd09e28ae8fc5f85a9/f5feee72e4f291fc/

image

Run 2: https://public-results-storage-prod.magento-testing-service.engineering/reports/magento/magento2/pull/38239/3e81af210aa85ebe41370fa39b7dcdb7/Functional/allure-report-ce/index.html#categories

image

engcom-Charlie avatar Jul 10 '25 06:07 engcom-Charlie