Magento Quality Patches Tool

repository·master·Indexed 41 days ago

https://github.com/magento/quality-patches

A CLI utility for delivering, applying, and reverting quality patches for Adobe Commerce and Magento Open Source. Supports On-Prem environments via the magento-patches script and Magento Cloud environments via the ece-patches script and .magento.env.yaml configuration.

Tokens
1.1K
Snippets
6
Records
7
Agent score
1%

What's inside Quality Patches Tool

  1. Install the Quality Patches Tool

    master

    Depending on your project type, use one of the following installation methods:

    On-Prem Project

    Install the package via Composer:

    composer require magento/quality-patches

    Cloud Project

    For Magento Cloud, the quality-patches package is a dependency of ece-tools (starting from v.2002.1.2). To install or update it, update your ece-tools package version.

    composer require magento/quality-patches
  2. Use the Quality Patches Tool on On-Prem projects

    master

    On On-Prem projects, use the ./vendor/bin/magento-patches script.

    Note: Always test patches in a pre-production environment. After applying patches, you must refresh the Magento cache via the Admin under System > Tools > Cache Management to reflect changes.

    ./vendor/bin/magento-patches
  3. Apply and revert patches manually in a local Cloud environment

    master

    To test patches locally before deploying to Cloud, follow these steps:

    Manual Application

    1. Add the desired patch IDs to the QUALITY_PATCHES variable in .magento.env.yaml.
    2. Run the apply command from the project root: ./vendor/bin/ece-patches apply Order of application: Cloud-required patches $\rightarrow$ Quality patches from .magento.env.yaml $\rightarrow$ Custom patches from /m2-hotfixes.
    3. Verify application with ./vendor/bin/ece-patches status.
    4. Clear the Magento cache: ./bin/magento cache:clean.

    Manual Reversion

    To clean your local instance, run: ./vendor/bin/ece-patches revert Order of reversion: Custom patches from /m2-hotfixes $\rightarrow$ Magento-quality patches $\rightarrow$ Cloud-required patches.

    # Apply patches locally
    ./vendor/bin/ece-patches apply
    
    # Check status locally
    ./vendor/bin/ece-patches status
    
    # Clear cache
    ./bin/magento cache:clean
    
    # Revert patches locally
    ./vendor/bin/ece-patches revert
  4. Apply patches in a Cloud project deployment

    master

    To apply patches during the Magento Cloud deployment process, add the QUALITY_PATCHES environment variable to your .magento.env.yaml file under the stage: build: section. Commit and push the updated file to your remote branch.

    stage:
        build:
            QUALITY_PATCHES:
                - MCTEST-1002
                - MCTEST-1003
  5. Understand patch status and type information

    master

    When running the status command, the tool provides information categorized by Status, Type, and Details.

    Status

    • Applied: The patch is already applied.
    • Not applied: The patch is not applied.
    • N/A: Status cannot be defined due to conflicts.

    Type

    • Optional: All patches from the Quality Patches Tool (optional for Cloud & On-Prem).
    • Required: All patches from Cloud Patches (required for Cloud, optional for On-Prem).
    • Deprecated: The patch is marked as deprecated; it is recommended to revert it and use a replacement.
    • Custom: Customer-specific patches from the m2-hotfixes folder (Cloud only).

    Details

    • Affected components: Lists the affected magento-modules.
    • Required patches: Shows patch dependencies.
    • Recommended replacement: Shows the patch recommended to replace a Deprecated patch.
  6. Manage patches via magento-patches CLI (On-Prem)

    master

    Use the following commands to manage patches in an On-Prem environment:

    • Check status: View available patches for your current Magento version.
    • Apply patches: Apply a specific list of patch IDs.
    • Revert patches: Revert specific patch IDs or all applied patches.
    # Show status of available patches
    ./vendor/bin/magento-patches status
    
    # Apply specific patches
    ./vendor/bin/magento-patches apply MAGETWO-95591 MAGETWO-67097
    
    # Revert specific patches
    ./vendor/bin/magento-patches revert MAGETWO-95591 MAGETTWO-67097
    
    # Revert all patches
    ./vendor/bin/magento-patches revert --all