Search

Tip: type a command such as theme build. Press Esc to close.

mageforge:template:obsolete

Find theme overrides that are no longer needed

Since v0.30.0Templatealias: template:obsolete

Run it

bin/magento mageforge:template:obsolete
bin/magento mageforge:template:obsolete Vendor/theme --deep
bin/magento mageforge:template:obsolete --delete
bin/magento mageforge:template:obsolete --format=json --fail-on-found

Finds theme overrides (<theme>/<Module_Name>/{templates,email,web}) that are no longer needed. In a terminal it shows the same searchable theme selection as mageforge:theme:build, then an options menu (Space to toggle) for the slower --deep check and for deleting the overrides that are safe to remove (deleting still asks for confirmation). Options already given as flags are not offered. Without a terminal (CI, pipes) or with --format=json all frontend themes outside vendor/ are checked and nothing is deleted unless --delete is given.

Arguments:

  • themeCodes — Themes to check (format: Vendor/theme), also vendor themes. Optional.

Options:

  • --deep — Also list templates without a found reference (slower, heuristic, may include templates that are still used).
  • --delete — Delete the overrides marked as safe (asks for confirmation) and clean the caches.
  • -y, --yes — Delete without confirmation.
  • --format=VALUE — table (default) or json.
  • --fail-on-found — Exit with a failure code if obsolete overrides exist (for CI).

Findings:

ReasonMeaningSafe to delete
IdenticalSame content as the file Magento would use without the overrideYes
OrphanedThe module is not installed/enabled, or the recorded source file no longer existsOnly if the module is missing
Possibly unused--deep: no reference to the .phtml template was found (hint only, see notes)No
OutdatedCopied from an older module version (taken from the MageForge header)No

Notes:

  • The comparison ignores the MageForge source header and line endings, and uses Magento's fallback rule, so parent themes and Hyvä compat modules are taken into account.
  • Theme layout files extend the module layout and are only checked for missing modules.
  • Possibly unused is only a hint and often a false positive. Templates can be used through widget.xml, di.xml, vendor layouts, the database (e.g. CMS blocks) or dynamically built paths, none of which are reliably detected. Never delete them without checking; --delete never touches them.

Version history

  • v0.30.0 – Add template:obsolete command to find unneeded them…