Skip to content
Nemanja Djuric edited this page Aug 12, 2022 · 17 revisions

Welcome to the m2-patches wiki!

On this page, you can find useful info on how to apply certain patches.

Magento2-Catalog-RabbitMQ

Filename: module-catalog.patch
Patch to convert product_action_attribute.update and product_action_attribute.website.update consumers from MySQL to RabbitMQ Broker

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

    "extra": {
        "magento-force": "override",
        "patches": {
            "magento/module-catalog": {
                "Catalog-RabbitMQ: product_action_attribute.update and product_action_attribute.website.update conversion to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-catalog.patch"
          }    
    }

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done, double-check if the RabbitMQ container is up and configured properly: https://magemojo.com/kb/best-practices/configuring-rabbitmq/

If everything is ready, the last step is to push setup:upgrade so Magento can generate queue within RabbitMQ service.

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Or if you have a custom deployment script or doing that externally.

Magento2-Media-RabbitMQ

Filenames: module-media-content-synchronization.patch,module-media-gallery-renditions.patch,module-media-gallery-synchronization.patch,module-media-storage.patch
Patch to convert media.content.synchronization, media.storage.catalog.image.resize, media.gallery.synchronization and media.gallery.renditions.update consumers from MySQL to RabbitMQ Broker

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

    "extra": {
        "magento-force": "override",
        "patches": {
            "magento/module-media-gallery-synchronization": {
                "Media-RabbitMQ: media.gallery.synchronization conversion to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-media-gallery-synchronization.patch"
            },
            "magento/module-media-gallery-renditions": {
                "Media-RabbitMQ: media.gallery.renditions.update conversion to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-media-gallery-renditions.patch"
            },
            "magento/module-media-content-synchronization": {
                "Media-RabbitMQ: media.content.synchronization conversion to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-media-content-synchronization.patch"
            },
            "magento/module-media-storage": {
                "Media-RabbitMQ: media.storage.catalog.image.resize conversion to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-media-storage.patch"
            }
          }
      }     

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with the internal subject name.
URL to patch: That’s the link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done, double-check if the RabbitMQ container is up and configured properly: https://magemojo.com/kb/best-practices/configuring-rabbitmq/

If everything is ready, the last step is to push setup:upgrade so Magento can generate queue within RabbitMQ service.

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Or if you have a custom deployment script or doing that externally.

Magento2-Inventory-RabbitMQ

Patch to convert inventory.source.items.cleanup inventory.mass.update inventory.reservations.cleanup inventory.reservations.update inventory.reservations.updateSalabilityStatus inventory.indexer.sourceItem inventory.indexer.stock consumers from MySQL to RabbitMQ Broker

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

    "extra": {
        "magento-force": "override",
        "patches": {
            "magento/module-inventory-catalog": {
                "Inventory-RabbitMQ: inventory.source.items.cleanup and inventory.mass.update to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-inventory-catalog.patch"
            },
            "magento/module-inventory-indexer": {
                "Inventory-RabbitMQ: inventory.indexer.sourceItem and inventory.indexer.stock conversion to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-inventory-indexer.patch"
            },
            "magento/module-inventory-sales": {
                "Inventory-RabbitMQ: inventory.reservations.update and inventory.reservations.cleanup conversion to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-inventory-sales.patch"
            }
          }
}

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done, double-check if the RabbitMQ container is up and configured properly: https://magemojo.com/kb/best-practices/configuring-rabbitmq/

If everything is ready, the last step is to push setup:upgrade so Magento can generate queue within RabbitMQ service.

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Or if you have a custom deployment script or doing that externally.

IMPORTANT INFO:
Please verify that env.php contains correct rabbit creds & the above-listed consumers are added to consumer_runners if you run consumers using Cron, otherwise it will not run. Also, after the patch is applied make sure that you execute setup:upgrade and verify if the queue is created within the RabbitMQ service.

queues created in rabbitmq

Small video demonstrating mass stock update:

Full resolution video you can watch here: https://www.youtube.com/watch?v=y5GMxOhZ22Y

Magento2-Import-Export-RabbitMQ

Filename: module-import-export.patch
Patch to convert exportProcessor consumer from MySQL to RabbitMQ Broker

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

    "extra": {
        "magento-force": "override",
        "patches": {
            "magento/module-import-export": {
                "Import-Export-RabbitMQ: exportProcessor conversion to amqp": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-import-export.patch"
          }    
    }

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done, double-check if the RabbitMQ container is up and configured properly: https://magemojo.com/kb/best-practices/configuring-rabbitmq/

If everything is ready, the last step is to push setup:upgrade so Magento can generate queue within RabbitMQ service.

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Or if you have a custom deployment script or doing that externally.

Magento2-Framework-PDO-Adapter-MySQL8

Filename: framework-adapter-pdo.patch
Patch to fix PDO Adapter when MySQL 8.0 used for Temporary tables using LIKE SQL query. According to MySQL doc pages: https://dev.mysql.com/doc/refman/8.0/en/create-temporary-table.html

You cannot use CREATE TEMPORY TABLE ... LIKE to create an empty table based on the definition of a table that resides in the mysql tablespace, InnoDB system tablespace (innodb_system), or a general tablespace. The tablespace definition for such a table includes a TABLESPACE attribute that defines the tablespace where the table resides, and the aforementioned tablespaces do not support temporary tables.

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

    "extra": {
        "magento-force": "override",
        "patches": {
            "magento/framework": {
                "Magento2-Framework-PDO-Adapter-MySQL8: Patch to fix PDO Adapter when MySQL 8.0 used for Temporary tables using LIKE SQL query": "https://raw.githubusercontent.com/magemojo/m2-patches/main/framework-adapter-pdo.patch"
          }    
    }

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done you may need to execute:

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Magento2-Framework-Stdlib-Cookie-PhpCookieManager

Filename: framework-stdlib-cookie-phpcookiemanager.patch
Patch to fix magento/framework/Stdlib/Cookie/PhpCookieManager.php and raise MAX_NUM_COOKIES from 50 to 300

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

    "extra": {
        "magento-force": "override",
        "patches": {
            "magento/framework": {
                "Magento2-Framework-Stdlib-Cookie-PhpCookieManager: Patch to fix magento/framework/Stdlib/Cookie/PhpCookieManager.php and raise MAX_NUM_COOKIES from 50 to 300": "https://raw.githubusercontent.com/magemojo/m2-patches/main/framework-stdlib-cookie-phpcookiemanager.patch"
          }    
    }

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done you may need to execute:

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Magento2-MDVA-43395-Security-Patch

Filenames: MDVA-43395_magento-framework.patch
Filenames: MDVA-43395_magento-module-email.patch
Patch to secure against https://sansec.io/research/magento-2-cve-2022-24086

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

"extra": {
        "magento-force": "override",
        "patches": {
            "magento/framework": {
                "MDVA-43395": "https://raw.githubusercontent.com/magemojo/m2-patches/main/MDVA-43395_magento-framework.patch"
            },
            "magento/module-email": {
                "MDVA-43395": "https://raw.githubusercontent.com/magemojo/m2-patches/main/MDVA-43395_magento-module-email.patch"
            }
        }
    }

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done you may need to execute:

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Magento2-MDVA-43443-Security-Patch

For versions 2.3.3-p1 - 2.3.4:
Filenames: MDVA-43443_EE_2.3.4_magento-framework.patch
Filenames: MDVA-43443_EE_2.3.4_magento-module-email.patch

For versions 2.3.4-p2 - 2.4.2-p2:
Filenames: MDVA-43443_EE_2.4.2-p2_magento-framework.patch
Filenames: MDVA-43443_EE_2.4.2-p2_magento-module-email.patch

For versions 2.4.3 - 2.4.3-p1:
Filenames: MDVA-43443_EE_2.4.3-p1_magento-framework.patch
Filenames: MDVA-43443_EE_2.4.3-p1_magento-module-email.patch

Patch decsription: https://support.magento.com/hc/en-us/articles/4426353041293-Security-updates-available-for-Adobe-Commerce-APSB22-12-

-- To apply patch --

The cweagans/composer-patches plugin should already be installed since this patch requires MDVA-43395

Edit the composer.json file and add the following section to specify (Make sure you are using correct version according to above):

 "extra": {
        "magento-force": "override",
        "patches": {
            "magento/framework": {
                "MDVA-43395": "https://raw.githubusercontent.com/magemojo/m2-patches/main/MDVA-43395_magento-framework.patch",
                "MDVA-43443": "https://raw.githubusercontent.com/magemojo/m2-patches/main/MDVA-43443_EE_2.4.3-p1_magento-framework.patch"
            },
            "magento/module-email": {
                "MDVA-43395": "https://raw.githubusercontent.com/magemojo/m2-patches/main/MDVA-43395_magento-module-email.patch",
                "MDVA-43443": "https://raw.githubusercontent.com/magemojo/m2-patches/main/MDVA-43443_EE_2.4.3-p1_magento-module-email.patch"
            }
        }
    }

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done you may need to execute:

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Magento2-Framework-Setup-Declaration-Schema-Dto-Table

Filename: 2-4-4-db-status-fix.patch
Patch to fix magento/framework/Setup/Declaration/Schema/Dto/Table.php and remove 'charset' => $this->getCharset(), from file based on https://github.com/magento/magento2/issues/35671

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

    "extra": {
        "magento-force": "override",
        "patches": {
            "magento/framework": {
                "Magento2-Framework-Setup-Declaration-Schema-Dto-Table: Patch to fix magento/framework/Setup/Declaration/Schema/Dto/Table.php and remove 'charset' => $this->getCharset(), from file based on https://github.com/magento/magento2/issues/35671": "https://raw.githubusercontent.com/magemojo/m2-patches/main/2-4-4-db-status-fix.patch"
          }    
    }

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

When this is done you may need to execute:

php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile

Magento2-Store-HSTS-Strict-Transport-Security-header-value-patch

Filename: module-store.patch
Patch to fix vendor/magento/module-store/Model/HeaderProvider/Hsts.php hardcoded header values https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Store/Model/HeaderProvider/Hsts.php#L28-L29 with option includeSubDomains If this optional parameter is specified, this rule applies to all of the site's subdomains as well.

-- To apply patch --

Add the cweagans/composer-patches plugin to the composer.json file.

composer require cweagans/composer-patches

Edit the composer.json file and add the following section to specify:

    "extra": {
        "magento-force": "override",
        "patches": {
            "magento/module-store": {
                "Magento2-Store-HSTS-Strict-Transport-Security-header-value-patch: Patch to fix vendor/magento/module-store/Model/HeaderProvider/Hsts.php hardcoded header values https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Store/Model/HeaderProvider/Hsts.php#L28-L29 with option includeSubDomains. If this optional parameter is specified, this rule applies to all of the site's subdomains as well.": "https://raw.githubusercontent.com/magemojo/m2-patches/main/module-store.patch"
          }    
    }

Text is added in the "extra": { section, with following content:

Explanations:
Module: "magento/module-name" ← That’s the Magento 2 Core module we are patching
Title: We link this with the internal subject name.
URL to patch: That’s link from above and our demo repository.

Apply the patch. Use the -v option only if you want to see debugging information.

composer -v install

Update the composer.lock file. The lock file tracks which patches have been applied to each Composer package in an object.

composer update --lock

Our patch just adds includeSubDomains to the Strict-Transport-Security header value with a maximum age. If you need your custom values, please use https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security article, fork our patch and adjust it per your requirements.

When this is done, you may need to execute:

php bin/magento config:set web/secure/enable_hsts 1
php bin/magento setup:upgrade --keep-generated
php bin/magento setup:di:compile