You are reading the documentation for version 2.2. Magento 2.3 is the latest version available. Ensure you are reading the documentation for your version of Magento.

Apply custom patches

Sometimes we provide a custom patch to address a specific issue. Also, third-party extension developers can provide a custom patch. Copy the custom patch to the /m2-hotfixes directory and test it on your local workstation.

Before beginning an upgrade or a patching process, create an active branch from the Integration environment and checkout the new branch to your local workstation. Dedicating a branch to the upgrade or the patch process helps to avoid interference with your work in progress.

To apply and test a custom patch:

You can only apply patches during the build phase of redeployment.

  1. On your local workstation, create a branch based on the integration branch.

    magento-cloud environment:branch <branch-name>
  2. Copy the patch file to the /m2-hotfixes directory.

  3. Add, commit, and push your code changes.

    git add -A && git commit -m "Apply patch" && git push origin <branch name>
  4. After test validation, merge this branch with the integration branch.

To test if a patch can be applied using your local workstation:

  1. From the project root, apply the patch.

    git apply ./m2-hotfixes/<patch-file-name>
  2. Clear the Magento cache.

    php ./bin/magento cache:clean

    You can also clean the cache using the Magento Admin Cache Management.

  3. Test the patch, make any necessary changes.