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-foundFinds 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) orjson.--fail-on-found— Exit with a failure code if obsolete overrides exist (for CI).
Findings:
| Reason | Meaning | Safe to delete |
|---|---|---|
| Identical | Same content as the file Magento would use without the override | Yes |
| Orphaned | The module is not installed/enabled, or the recorded source file no longer exists | Only if the module is missing |
| Possibly unused | --deep: no reference to the .phtml template was found (hint only, see notes) | No |
| Outdated | Copied 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 unusedis only a hint and often a false positive. Templates can be used throughwidget.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;--deletenever touches them.
Version history
- v0.30.0 – Add template:obsolete command to find unneeded them…