I am developing a custom module on Magento 2.4.4-p11 to improve site performance.
My pre-production environment is a clone of production (same Redis, Varnish, PHP, Apache configuration).
I override the block MagentoCmsBlockWidgetBlock using a DI preference. The override works as expected in pre-production, but does not apply in production.
Both environments:
-
Run in production mode
-
Use Varnish Full Page Cache
-
Have OPcache enabled
OPcache configuration:
opcache.enable = On
opcache.file_cache_consistency_checks = On
opcache.file_cache_only = Off
opcache.revalidate_freq = 1
opcache.revalidate_path = Off
opcache.validate_permission = Off
opcache.validate_timestamps = Off
Has anyone experienced a similar issue where a DI preference works in pre-prod but not in prod? Any insight into possible causes (DI compilation, generated code, opcache, FPC, etc.) would be appreciated.
di.xml
<preference for="MagentoCmsBlockWidgetBlock"
type="VendorExtensionBlockWidgetBlock" />
Custom block
class Block extends MagentoCmsBlockWidgetBlock
{
public function __construct(
Context $context,
FilterProvider $filterProvider,
BlockFactory $blockFactory,
private readonly CmsBlock $blockModel,
private readonly CacheInterface $cache,
array $data = []
) {
parent::__construct($context, $filterProvider, $blockFactory, $data);
}
}