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 Magento Quality Patch (MQP) tool 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 can be applicable to other versions. To check if the patch is compatible with your Magento version, run
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/<project id>/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 MQP patch, use the following links depending on your Magento product:
- Magento Commerce: DevDocs Apply patches using Magento Quality Patches Tool.
- Magento Commerce Cloud: DevDocs Upgrades and Patches > Apply patches.
To learn more about Magento Quality Patches, refer to:
- Magento Quality Patches released: a new tool to self-serve quality patches.
- Check if patch is available for your Magento issue using Magento Quality Patches.
For info about other patches available in MQP tool, refer to the Patches available in MQP tool section.