Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added theme is not registered during production mode #2797

Closed
moleman opened this issue Dec 23, 2015 · 40 comments
Closed

Added theme is not registered during production mode #2797

moleman opened this issue Dec 23, 2015 · 40 comments
Labels
Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@moleman
Copy link

moleman commented Dec 23, 2015

It seems that added / installed themes are not registered if they are added to a site which is already installed and is set to production mode. By registered I mean that they are not added to the theme table.

After looking at the code it seems that themes are registered differently depending on mode.

In developer mode:

In production mode:

This means that if you have a running site in production mode and you decide to install a new theme it will not be registered in the theme table which means that it will not be selectable in the admin.

Steps to reproduce:

  1. Install Magento2, run the installation wizard
  2. Set deploy mode to production, php bin/magento deploy:mode:set production
  3. Add a theme with: composer require
  4. Run php bin/magento setup:upgrade

Expected result:

The installed theme should be registered in the theme table.

Actual result:

The installed theme is not registered in the theme table.

@slavvka slavvka added the CS label Dec 23, 2015
@slavvka slavvka self-assigned this Dec 23, 2015
@slavvka
Copy link
Member

slavvka commented Dec 23, 2015

Hi @moleman. Thank you for your inquiry but it is not a bug. Such actions like updating code, adding themes etc aren't supposed to be performed on production since they may lead to unpredictable and unstable site work. Usually such changes should be done not in production mode on some staging server and lately published on production.

@slavvka slavvka closed this as completed Dec 23, 2015
@moleman
Copy link
Author

moleman commented Dec 23, 2015

@slavvka Yes, and that is what we do. We have a build server that builds the sites cleanly with Composer and this is where the new code is introduced. These build artifacts are then deployed to staging and production servers and we then run setup:upgrade to upgrade the database in production after the deployment of the code is done.

So, whats the correct workflow then when you want to add a new theme to a production site so that the theme gets registered in the theme database table? Because currently if we add a new theme it never gets registered because of the issue above.

@davidalger davidalger reopened this Dec 23, 2015
@davidalger
Copy link
Member

@slavvka This may not sound like a bug at first read, but the OP isn't talking about developing on a production site, but rather a deployment procedure. There are CLI commands to enable/disable modules, and to "uninstall" a theme, but none to install/activate/register a theme. Builds must be pushed to production in some fashion, and then setup:upgrade run to execute install scripts, and new components moving to production as part of a build need to be registered somehow, whether that is automatic when setup:upgrade is done (as would be expected) or at minimum via a CLI command to register them with the system so it knows about them.

If there is an existing mechanism in the system to roll non-module components out to production and register them without re-installing the software from scratch, it would be great if you could make note of what that is. If there isn't a way to do this, then it is a bug and needs to be solved.

@davefarthing
Copy link
Contributor

I have the same experience. Similarly we are not attempting to install a theme directly to production, rather we are installing/creating a theme in dev. then much like @moleman, we use composer to generate a fresh code instance on a clean server before deploying the updated code to the production environment. The successful deployment then triggers 'setup:upgrade' to be run on the production servers in order to run the module updates and schema upgrades. _(I see no other sensible way of performing data-install and updates on the production DB...)_

None of this process adds a new theme record to the 'theme' table so not sure how this is supposed to be achieved.... set the site to developer mode to allow the theme to register... surely not!

I too am interested in what approach is therefore recommended be to update the theme records (and other schema / record changes) in a production environment if this is by "design".

Surely this is a bug that needs fixing.....

@mazhalai
Copy link
Contributor

Thank you all for your input, we have created MAGETWO-47999 to fix it.

@mazhalai mazhalai added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jan 15, 2016
@MomotenkoNatalia MomotenkoNatalia added PS and removed CS labels Jan 19, 2016
@mazhalai
Copy link
Contributor

mazhalai commented Mar 8, 2016

@moleman thank you for reporting. We have merged a fix in the develop branch, hence closing this ticket. Please create a new ticket if issues still arise.

@davidalger
Copy link
Member

@mazhalai Could you comment on what the ultimate fix was/is? I'm not seeing commits tagged with this GH issue id, and it's unclear from the thread if this was being fixed by having setup:upgrade add the theme or via some other means.

@mazhalai
Copy link
Contributor

@davidalger
Copy link
Member

Based on commit 0132caf it looks like they should now be auto-registered when setup:upgrade is run. Thanks @mazhalai!

@woei66
Copy link

woei66 commented Mar 29, 2016

@mazhalai

How do I know that the patch will be available for production if I install magento2 by below command:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2

thank you.

@Igloczek
Copy link
Contributor

Igloczek commented Apr 8, 2016

@mazhalai @slavvka @davidalger @alankent
Could you provide some "estimated release version" info marking issue as resolved by your internal ticket ID, to let us know when it should be released?

I spend a lot of time trying to figure out if that fix was released or not and still have no idea...
Official release notes also don't contains any info about resolved github/internal issues, so how we can know what was fixed?

@mazhalai
Copy link
Contributor

mazhalai commented Apr 8, 2016

@Igloczek the fix is in the develop branch, but it hasn't been added to a release yet.

The way to tell if a fix is in a release version:

@Igloczek
Copy link
Contributor

Igloczek commented Apr 8, 2016

Don't you think this is a ridiculous "solution" for tracking issues status?

@mazhalai
Copy link
Contributor

mazhalai commented Apr 8, 2016

@Igloczek sorry we cannot share access to our internal tracking.

@Igloczek
Copy link
Contributor

Igloczek commented Apr 8, 2016

How about Github milestones and referencing Github issues in commit messages?

@heldchen
Copy link
Contributor

heldchen commented Apr 8, 2016

@mazhalai can you at least shed some light on when the patch might make it into an official release? according to this ticket this bug was fixed mid january - since then 4 release versions happened...

@mazhalai
Copy link
Contributor

mazhalai commented Apr 8, 2016

@Igloczek yes I apologize for the Github issue in the commit message, but we do not track Github milestones in tickets.

@heldchen It was fixed in mid Feb and contributed in Mar, not Jan. @elenleonova any comment on next patch release date?

@peec
Copy link

peec commented Apr 27, 2016

Finally found this issue! So basically right now custom themes does not register. I did not understand why my theme did not appear, but this explains everything.

@woei66
Copy link

woei66 commented Apr 28, 2016

hi, @mazhalai
Is the bug fixed in 2.0.4 version?
I had upgrade my magent2 to 2.0.4 but I still can't register my customized theme.
Any suggestion to verify step by step?
thank you.

@peec
Copy link

peec commented Apr 28, 2016

@woei66 No this is not added in 2.0.X yet ( It's just in develop branch ) and not 2.0:

2.X branch: https://github.com/magento/magento2/blame/2.0/app/code/Magento/Theme/Model/Theme/Registration.php

vs

Develop: https://github.com/magento/magento2/blame/develop/app/code/Magento/Theme/Model/Theme/Registration.php

Search for MAGETWO-47999

on both of those links, you see that the fix is only in develop branch!

This fix is urgent. Please add to 2.0.5!

@Igloczek
Copy link
Contributor

@benmarks @maksek
That's what I'm talking about on Developers Paradise - we have closed issue, resolved by some of your internal ticket (without referencing github issue in commit msg) and merged into develop - AFAIK it should be available in next release.
But... two months and two releases later - still not available, no one knows when it should be added to stable version 😥

@vduglued
Copy link

vduglued commented May 2, 2016

What's the proper/recommended fix until this goes into a prod. release? Switch production to developer mode, run upgrade, and switch back?

EDIT: my dev env is in "developer" mode and the theme files are all present. Running upgrade doesn't register the theme either.

@Igloczek
Copy link
Contributor

Igloczek commented May 2, 2016

I fix it on production using SQL query to manually add record to theme table.

@vduglued
Copy link

vduglued commented May 2, 2016

Thanks @Igloczek - the direct SQL insert seems like the quick option.

@peec
Copy link

peec commented May 4, 2016

Not fixed in 2.0.5 either.

THE PROBLEM

=== frontend -> Magento/luma -> nb_NO ===
.................................................................................................................................................................................................................
Successful: 2038 files; errors: 0
---

=== frontend -> MyVendor/Base -> nb_NO ===
Unable to load theme by specified key: 'MyVendor/Base'>

NOW LETS SEE:

mysql> select * from theme;
+----------+-----------+-----------------+-------------------+----------------------------------+-------------+-----------+------+-----------------+
| theme_id | parent_id | theme_path      | theme_title       | preview_image                    | is_featured | area      | type | code            |
+----------+-----------+-----------------+-------------------+----------------------------------+-------------+-----------+------+-----------------+
|        1 |      NULL | Magento/blank   | Magento Blank     | preview_image_5710e776daadc.jpeg |           0 | frontend  |    0 | Magento/blank   |
|        2 |         1 | Magento/luma    | Magento Luma      | preview_image_5710e776ee428.jpeg |           0 | frontend  |    0 | Magento/luma    |
|        3 |      NULL | Magento/backend | Magento 2 backend | NULL                             |           0 | adminhtml |    0 | Magento/backend |
+----------+-----------+-----------------+-------------------+----------------------------------+-------------+-----------+------+-----------------+

3 rows in set (0,06 sec)

TEMPORARY SOLUTION:

mysql> insert into theme (parent_id,theme_path,theme_title,preview_image,is_featured,area,type,code) \
       VALUES ('1','MyVendor/Base','MyVendor Base', NULL, 0, 'frontend', 0, 'MyVendor/Base');

@maksek
Copy link
Contributor

maksek commented May 10, 2016

@peec all fixes from github are targeting 2.1 release, you won't see them in patch releases yet. For this particular i got confirmation - will be targeting 2.0.7

@hectornguyen
Copy link

I'm using Magento 2.0.7 at this moment, and seem it still not be patched yet.

@ClaudiuCreanga
Copy link

Can someone update the documentation and explain what are virtual and staging theme types and when to use them? Can't find anything about it. Thanks!

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Aug 25, 2016

@maksek @mazhalai this fix was reverted in c4e5f32 and this issue still exists.

Could you re-open it and fix?

@erikhansen
Copy link
Contributor

@maksek @mazhalai I'm still seeing this issue on 2.1.2 as well. Is there a new ticket open that covers this issue?

@gil--
Copy link
Member

gil-- commented Dec 9, 2016

@erikhansen agreed. Just ran into this and followed @peec mysql code to resolve it.

@jpratt
Copy link

jpratt commented Dec 17, 2016

Anyway around this in production mode, using 2.1.0? I tried adding it directly in the theme table and appears to be successful, however then get an error saving products 'Required Parameter theme_dir was not passed'. If I remove the theme I entered manually in the table the error goes away when saving products. @gil-- have you tested saving products after adding the row manually?

@Igloczek
Copy link
Contributor

Igloczek commented Dec 17, 2016

@jpratt are you 100% sure that theme_dir was correct?
Solution with manual adding them via SQL query is 100% correct and works well for us and as you can see by votes, many other ppl.

@avra911
Copy link

avra911 commented Mar 8, 2017

@Igloczek running setup:upgrade doesn't detect and add the new design into the theme table as well?

When I tried it, I only notices is adding 1 instead of 0 in TYPE column.

@leoquijano
Copy link

I'm having this problem in v2.2.3 as well. This is causes problems when testing new themes in integration/staging websites, which are usually set to production mode to mimic the live site as closely as possible.

My workaround for that is to switch to developer mode, load the admin (so the row in the theme table gets created), and then switch back to production mode. This is in case someone would like to avoid manual updates to the DB.

The fix should really be formally included in releases before closing the Github issue. No integrator would use the develop branch when working with actual websites.

@slackerzz
Copy link
Member

This bug is still present in 2.2.5.
@magento-engcom-team maybe this issue should be reopened

@penglongyun
Copy link

This bug is still present, I add a custom adminhtml theme,but not working in developer mode

@Igloczek
Copy link
Contributor

Igloczek commented Sep 4, 2018

@penglongyun admin themes work differently, your problem it's probably not related to this issue.
Check the docs for details:

@OvalMedia
Copy link

2.4.3-p1 And still not fixed.
The idea behind it is not based on real world problems. In my case I created a new subtheme that would be used in a new feature. This theme was supposed to be scheduled automatically. I relied on my deployment script to take care of installing the new theme and just by chance i saw it wasn't there. The automatic scheduling would have hit a brick wall.

But I assume since this issue is closed nobody will care...

@slackerzz
Copy link
Member

@OvalMedia while this is issue is not fixed you can now dump your themes in app/etc/config.php to be sure that the themes are registered, e.g.:

<?php
return [
    'modules' => [...],
    'themes' => [
        'frontend/Magento/blank' => [
            'parent_id' => null,
            'theme_path' => 'Magento/blank',
            'theme_title' => 'Magento Blank',
            'is_featured' => '0',
            'area' => 'frontend',
            'type' => '0',
            'code' => 'Magento/blank'
        ],
        'adminhtml/Magento/backend' => [
            'parent_id' => null,
            'theme_path' => 'Magento/backend',
            'theme_title' => 'Magento 2 backend',
            'is_featured' => '0',
            'area' => 'adminhtml',
            'type' => '0',
            'code' => 'Magento/backend'
        ],
        'frontend/Magento/luma' => [
            'parent_id' => 'Magento/blank',
            'theme_path' => 'Magento/luma',
            'theme_title' => 'Magento Luma',
            'is_featured' => '0',
            'area' => 'frontend',
            'type' => '0',
            'code' => 'Magento/luma'
        ],
        'frontend/MyVendor/MyTheme => [
            'parent_id' => 'Magento/luma',
            'theme_path' => 'MyVendor/MyTheme',
            'theme_title' => 'MyVendor MyTheme',
            'is_featured' => '0',
            'area' => 'frontend',
            'type' => '0',
            'code' => 'MyVendor/MyTheme'
        ]
    ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests