Skip to content

Register Magento 2 themes when a release changes the theme set - #4263

Open
michielgerritsen wants to merge 1 commit into
deployphp:masterfrom
michielgerritsen:magento2-theme-registration
Open

michielgerritsen wants to merge 1 commit into
deployphp:masterfrom
michielgerritsen:magento2-theme-registration

Conversation

@michielgerritsen

Copy link
Copy Markdown
Contributor
  • Bug fix #…?
  • New feature?
  • BC breaks?
  • Tests added?
  • Docs added?

Theme registration is part of Magento's data upgrade, which the recipe only runs when setup:db:status asks for it. A release that changes nothing but the set of themes, Hyvä 1.5 dropping its reset theme for example, therefore leaves the theme table pointing at a directory that no longer exists, and every page fails with Required parameter 'theme_dir' was not passed. This fingerprints the theme.xml files in the release, compares that with what the last deploy registered, and runs setup:db-data:upgrade when it differs, which is the cheapest command that triggers Magento_Theme's recurring data script: 1.7s on a mid-size shop, measured against a deliberately broken theme table. theme_registration_needed feeds upgrade_needed, so maintenance mode brackets it exactly like a db upgrade, and a db or full upgrade stands the check down because it registers themes anyway.

One thing to watch out for: a vendor bumping a theme <title> counts as a change, so it costs one no-op data upgrade inside maintenance. Erring that way seemed better than missing a re-parented theme.

Two notes on the test. It uses one import with a host per scenario because recipe/magento2.php declares a top-level function, so importing it twice in one process is already fatal, and its fixture requires recipe/common.php explicitly because the require_once in the recipe skips it when another spec loaded it earlier in the same process. Happy to split either of those off if you would rather see them fixed separately.

Theme registration is part of Magento's data upgrade, which the recipe only
runs when setup:db:status asks for it. A release that changes nothing but the
set of themes leaves the theme table pointing at a directory that is gone, and
every page fails with "Required parameter 'theme_dir' was not passed".

Fingerprint the theme.xml files of the release, compare that with what the last
deploy registered, and run setup:db-data:upgrade when it differs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant