The MDVA-31307 Magento patch fixes the issue where Magento_Csp/Model/BlockCache consumes a lot of memory and generates enormous cached strings, which causes problems for certain pages with a lot of dynamically whitelisting scripts and styles. The provided patch optimizes this process.This patch is available when the Quality Patches Tool (QPT) 1.0.19 is installed. The patch ID is MDVA-31307. Please note that the issue is fixed in Magento 2.4.2.
Affected products and versions
The patch is created for Magento version: Magento Commerce Cloud 2.4.0
Compatible with Magento versions: Magento Commerce and Magento Commerce Cloud 2.4.0 - 2.4.1-p1
Note: the patch might become applicable to other versions with new QPT tool releases. To check if the patch is compatible with your Magento version, run
./vendor/bin/magento-patches status .
Fixes the issue where there are Out of memory errors on certain categories due to problems with dynamic CSP whitelisting for cached blocks.
Steps to reproduce:
- Generate small profile fixtures (
- Open all category pages in different tabs.
[date and time] PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 90112 bytes) in Unknown on line 0 [date and time] PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 33554440 bytes) in /app/
/vendor/magento/module-csp/Model/Collector/DynamicCollector.php on line 31
All the pages have opened correctly.
Apply the patch
For instructions on how to apply an QPT patch, use the following links depending on your Magento product:
- Magento Commerce: DevDocs Apply patches using Quality Patches Tool .
- Magento Commerce Cloud: DevDocs Upgrades and Patches > Apply patches .
To learn more about Quality Patches Tool, refer to:
- Quality Patches Tool released: a new tool to self-serve quality patches .
- Check if patch is available for your Magento issue using Quality Patches Tool .
For info about other patches available in QPT tool, refer to the Patches available in QPT tool section.