Shared on Mage Dispatch · 02 Sep 2026

Script to fix wrong cache encryption key after upgrading to 2.4.8

Up to 2.4.7 Magento\Catalog\Model\View\Asset\Image::getMiscPath() hashed the image parameters with the installation's encryption key (hash_hmac); from 2.4.8 on it is a plain md5 over the same string, with the note "New paths are generated without dependency on an encryption key".

Every existing directory under pub/media/catalog/product/cache/ therefore has a name the storefront no longer asks for. The files themselves are unchanged. On a theme that does not resize on render, every product image returns 404 until
bin/magento catalog:images:resize has rebuilt the whole catalogue: 11k images took an estimated 6.5 hours on our shop.

This script calculates both names per image variant and renames the directory instead, which takes minutes. It verifies its own arithmetic first: the new name it calculates must equal the one in the url Magento produces, and it aborts without touching anything if a single variant disagrees. A target directory that already exists is filled in with rsync --ignore-existing, so a resize that is already running is never overwritten.

Visit link → https://gist.github.com/henkvalk/99429e8831596ef464af00522aff627c

New here? This is Mage Dispatch

Mage Dispatch is a community-run archive and bi-weekly newsletter for the Magento, Adobe Commerce and Mage-OS ecosystem. Modules, articles, security advisories and tools, hand-picked by developers and shared so good work does not disappear into the void.

Browse the latest links → Explore by topic → Submit a link → About us →