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

Can't change the applied theme in 2.2.4 #14968

Closed
Krapulat opened this issue May 3, 2018 · 119 comments
Closed

Can't change the applied theme in 2.2.4 #14968

Krapulat opened this issue May 3, 2018 · 119 comments
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@Krapulat
Copy link

Krapulat commented May 3, 2018

Preconditions

  1. Magento 2.2.4
  2. PHP 7.1

Steps to reproduce

  1. Go to Content > Design > Configuration
  2. Edit the Store View and try to change the "Applied theme" to another
  3. Save Configuration

Expected result

  1. Change the theme

Actual result

  1. Appears the error: "Something went wrong while saving this configuration: Area is already set"
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label May 3, 2018
@ne0nlight
Copy link

Can verify, also experiencing this exact issue.

@hostep
Copy link
Contributor

hostep commented May 3, 2018

Indeed, can confirm as well on a clean 2.2.4 installation.
It only happens on storeview level, on website or global level, it works as expected.

I can not reproduce this on a clean 2.2.3 installation, so it looks like this is a new bug in 2.2.4, yay!

@sferreira-nicopu
Copy link

sferreira-nicopu commented May 3, 2018

@sferreira-nicopu just adding myself to the conversation since we experienced the same issue yesterday after updating our Magento Commerce Cloud to this version

@SamB-GB
Copy link

SamB-GB commented May 4, 2018

I am seeing this issue as well but trying to update logo and save.

@gtlt
Copy link

gtlt commented May 4, 2018

+1
Class Magento\Email\Model\AbstractTemplate :
$this->area is already setted to adminhtml when $this->emailConfig->getTemplateArea($templateId) return frontend.
note: $templateId is equal to "design_email_header_template"

    public function setForcedArea($templateId)
    {
        if ($this->area) {
            throw new \LogicException(__('Area is already set'));
        }
        $this->area = $this->emailConfig->getTemplateArea($templateId);
        return $this;
    }

shouldn't we have this code instead ??

   public function setForcedArea($templateId)
    {
        if (!isset($this->area)) {
           $this->area = $this->emailConfig->getTemplateArea($templateId);
        }
        return $this;
    }

here a stacktrace :

[2018-05-04 10:44:23] main.CRITICAL: Exception message: Area is already set
Trace: #0 /var/www/mysite/www.mysite/vendor/magento/module-theme/Model/Design/Config/Validator.php(117): Magento\Email\Model\AbstractTemplate->setForcedArea('design_email_he...')
#1 /var/www/mysite/www.mysite/vendor/magento/module-theme/Model/Design/Config/Validator.php(68): Magento\Theme\Model\Design\Config\Validator->getTemplateText('design_email_he...', Object(Magento\Theme\Model\Data\Design\Config))
#2 /var/www/mysite/www.mysite/vendor/magento/module-theme/Model/DesignConfigRepository.php(91): Magento\Theme\Model\Design\Config\Validator->validate(Object(Magento\Theme\Model\Data\Design\Config))
#3 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Theme\Model\DesignConfigRepository->save(Object(Magento\Theme\Model\Data\Design\Config))
#4 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Theme\Model\DesignConfigRepository\Interceptor->___callParent('save', Array)
#5 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Theme\Model\DesignConfigRepository\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Theme\Model\Data\Design\Config))
#6 /var/www/mysite/www.mysite/generated/code/Magento/Theme/Model/DesignConfigRepository/Interceptor.php(39): Magento\Theme\Model\DesignConfigRepository\Interceptor->___callPlugins('save', Array, Array)
#7 /var/www/mysite/www.mysite/vendor/magento/module-theme/Controller/Adminhtml/Design/Config/Save.php(75): Magento\Theme\Model\DesignConfigRepository\Interceptor->save(Object(Magento\Theme\Model\Data\Design\Config))
#8 /var/www/mysite/www.mysite/generated/code/Magento/Theme/Controller/Adminhtml/Design/Config/Save/Interceptor.php(24): Magento\Theme\Controller\Adminhtml\Design\Config\Save->execute()
#9 /var/www/mysite/www.mysite/vendor/magento/framework/App/Action/Action.php(107): Magento\Theme\Controller\Adminhtml\Design\Config\Save\Interceptor->execute()
#10 /var/www/mysite/www.mysite/vendor/magento/module-backend/App/AbstractAction.php(229): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#11 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#12 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Theme\Controller\Adminhtml\Design\Config\Save\Interceptor->___callParent('dispatch', Array)
#13 /var/www/mysite/www.mysite/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Theme\Controller\Adminhtml\Design\Config\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#14 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Theme\Controller\Adminhtml\Design\Config\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#15 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Theme\Controller\Adminhtml\Design\Config\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#16 /var/www/mysite/www.mysite/generated/code/Magento/Theme/Controller/Adminhtml/Design/Config/Save/Interceptor.php(39): Magento\Theme\Controller\Adminhtml\Design\Config\Save\Interceptor->___callPlugins('dispatch', Array, NULL)
#17 /var/www/mysite/www.mysite/vendor/magento/framework/App/FrontController.php(55): Magento\Theme\Controller\Adminhtml\Design\Config\Save\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#18 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#19 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#20 /var/www/mysite/www.mysite/vendor/mymodule/m2-module-core/Plugin/App/FrontController.php(122): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#21 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(135): Module\Core\Plugin\App\FrontController->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#22 /var/www/mysite/www.mysite/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#23 /var/www/mysite/www.mysite/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#24 /var/www/mysite/www.mysite/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#25 /var/www/mysite/www.mysite/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
#26 /var/www/mysite/www.mysite/vendor/magento/framework/App/Bootstrap.php(256): Magento\Framework\App\Http\Interceptor->launch()
#27 /var/www/mysite/www.mysite/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#28 {main} [] []

@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels May 4, 2018
@13CHILLIES
Copy link

getting the same fault.

@magentochile
Copy link

Hi gtlt,
You are absolutely right in the world !!!
When we change in Magento\Email\Model\AbstractTemplate.php this:
public function setForcedArea($templateId)
{
if ($this->area) {
throw new \LogicException(__('Area is already set'));
}
$this->area = $this->emailConfig->getTemplateArea($templateId);
return $this;
}

For this:
public function setForcedArea($templateId)
{
if (!isset($this->area)) {
$this->area = $this->emailConfig->getTemplateArea($templateId);
}
return $this;
}
work!!! And they fill correctly core_config_data and design_config_grid_flat:

core_config_data: https://www.magentochile.cl/blog/wikis-images/bug/core_config_data.jpg

design_config_grid_flat: https://www.magentochile.cl/blog/wikis-images/bug/design_config_grid_flat.jpg

@DanielRuf
Copy link
Contributor

DanielRuf commented May 8, 2018

Would be good to have some regression testing for such things to potentially prevent such issues. How can we help here with tests?

@gtlt
Copy link

gtlt commented May 8, 2018

@magentochile the class Magento\Email\Model\AbstractTemplate didn't changed since last August, so I'm not sure changing the method setForcedArea is the right solution, I didn't investigated to check if it has side effects (like on email generation, etc).

@itsmeit268
Copy link

Hi, I also met the same problem

@tomasmarcik
Copy link

Same issue. Applied the code from above but I don't expect this is final solution. When it will be fixed?

@magentochile
Copy link

Dear sirs, I think you have to look at:

$this->area = isset($data['area']) ? $data['area'] : null;

And trace it back as far as it goes ... now I'm setting up a Magento 2 store and I'm not letting go ... if I manage to finish the store, I'll follow up. Maybe see what he throws with a:
echo $data['area'];
var_dump($data['area']);

and look what it throws ... what's in $data['area'] that says it Area is already set!

@DanielRuf
Copy link
Contributor

Hm, if the class did not change did the interface or consumers change its usage?

@kunsal
Copy link

kunsal commented May 9, 2018

Trying to change theme in fresh Magento 2.2.4 threw error "Something went wrong while saving this configuration: Area is already set". Any fix yet?

@bhaveybansal
Copy link

I'm too facing this issue on fresh install of magento 2.2.4

@pocketprogrammer
Copy link

I experience the same issue on fresh install of 2.2.4

Not sure if this helps, but I CAN save the theme at the website level. The error only occurs for me at the store view level. Changing the theme and saving at the website level updates the store view's theme.

@DanielRuf
Copy link
Contributor

Right, global and website level work but not the store view level.

@chrisjefferies
Copy link

chrisjefferies commented May 9, 2018

I am also having this issue. 2.2.4.

I was able to get around it by changing the theme_id value in core_config_data table manually. No known side effects yet.

@mariamghalleb
Copy link

mariamghalleb commented May 9, 2018

Ive also start having this problem since I upgraded from 2.2.3 to 2.2.4 ...

@DanielRuf
Copy link
Contributor

I'll give it a try and try some bisecting tomorrow since this seems to affect many users and we do not yet have a solution or the cause of this.

@andersonsaraivaswe007
Copy link

Experiencing the same issue here Magento 2.2.4

@magentochile
Copy link

magentochile commented May 9, 2018

Hey friends,

I stopped at my work, and I took another look at the error. And I did the essay to add echo $this->area, but in the "throw new" and it gave me the following result:

public function setForcedArea($templateId)
{
if ($this->area) {
// throw new \LogicException(('Area is already set'));
throw new \LogicException(
($this->area));
}
$this->area = $this->emailConfig->getTemplateArea($templateId);
return $this;
}

And it gave me the result of:
Something went wrong while saving this configuration: adminhtml

The area "adminhtml" is that I think you should not assign the area to what corresponds to the frontend template. Here is documentation of that: https://devdocs.magento.com/guides/v2.0/architecture/archi_perspectives/components/modules/mod_and_areas.html

So what could be done a small fix, although it's not the right thing, could be like that (other than the "adminhtml" area):

public function setForcedArea($templateId)
{
// if ($this->area) {
if ($this->area !== 'adminhtml') {
throw new \LogicException(__('Area is already set'));
}
$this->area = $this->emailConfig->getTemplateArea($templateId);
return $this;
}
Look at the image below:
https://www.magentochile.cl/blog/wikis-images/bug/save-adminhtml-area.jpg

Regards,

Boris Durán R.

@DanielRuf
Copy link
Contributor

This is the cause.

git bisect bad
d3aef7c3eef658baa00d3233d0352b5fed0f1cbe is the first bad commit
commit d3aef7c3eef658baa00d3233d0352b5fed0f1cbe
Author: Andrii Meysar <andrii.meysar@transoftgroup.com>
Date:   Wed Mar 21 18:16:42 2018 +0200

    MAGETWO-89261: Template file 'header.html' is not found.

:040000 040000 7437b710bf3a7e2a357f9bfd71a6d488aa225812 9f8cf78d8757c7a8d1aa17ad0ec0b2ef6b433cf2 M      app

@EzzyEcom
Copy link

EzzyEcom commented Jul 7, 2018

@ghermans you can accomplish this 2 or 3 different ways.

  1. update directly the deployed core code located here,
    vendor/magento/module-email/Model/AbstractTemplate.php:535'ish

  2. apply a git patch (I don't have the SHA for this option, but maybe someone @here could chime-in)

  3. create a plugin yourself that will use dependency injection and setForcedArea like this

public function setForcedArea($templateId)
    {
        if (!isset($this->area)) {
         $this->area = $this->emailConfig->getTemplateArea($templateId);   
        }
        return $this;
    }
  1. Use an existing composer ready module like this one
    https://github.com/pfortin-expertime/MageFix-Misc

Good luck

@ghermans
Copy link

ghermans commented Jul 7, 2018

Thanks for the quick response and detailed feedback.

@hostep
Copy link
Contributor

hostep commented Jul 7, 2018

Additional: for number 2 of @EzzyEcom, use this method: https://support.magento.com/hc/en-us/articles/360005484154 to apply this commit using composer.

@rowneybury
Copy link

Hi Guys, Sorry, am a real newbie but have just spent a fair bit of money on having a Magento site designed for me in 2.2.5 and now I find I can't make any basic changes like logo for example which makes my site useless?? Does this happen often in Magento? I came over from Sellerdeck and now wishing I hadn't :-(

@EzzyEcom
Copy link

EzzyEcom commented Jul 7, 2018

@rowneybury most logos and images are database/admin configurations.
along with CSS styling being some of the easiest changes that will definitely be vital to your site's up-keeping.
Word of advice, retain an agency or a Magento2 freelancer fullstack dev on like 10 hours a month basis to work thru all those bits and pieces you find yourself frustrated over.

Sorry @everyoneelse I know this topic is not related to this #15137 but I just had to help the next guy over.

@rowneybury
Copy link

@EzzyEcom Thanks for the prompt reply. Unfortunately I don't have the funds to have a developer on retainer. I'm surprised that this issue was known about in version 2.2.4 yet is still a problem in 2.2.5?? Odd way to work.

Thanks again for the reply

@EzzyEcom
Copy link

EzzyEcom commented Jul 7, 2018

@rowneybury #15137 fix sounds like had a hiccup when it comes to being deployed on 2.2.5, but as mentioned previously in here, this will be automatically added by deploy bots on 2.2.6 in roughly about 2 months from now, if my math is right.

In the mean time, if your site was built leveraging Magento 2 modularity architecture by means of composer, then you can easily rollback version from 2.2.5 to 2.2.3 and go on for a while until 2.2.6 rolls out.

The other option is to patch your current version by following this simple GIT / composer instructions, Create a patch for a Magento 2 Composer to add commit SHA ...e9cb4ef2

@rowneybury
Copy link

Thanks again, I do appreciate the help. I think I need to speak to the company who installed my Magento and see if they can roll it back to 2.2.3, sounds like the easiest option. I will click the link you provided for creating a patch but fear it will mean nothing to me! :-)

Enjoy the rest of your weekend.

ihor-sviziev pushed a commit to ihor-sviziev/magento2 that referenced this issue Jul 10, 2018
Squashed commit of the following:

commit db9fa53cce1c8042caf24c855cfc18d1d948a6b8
Author: Daniel Ruf <daniel@daniel-ruf.de>
Date:   Thu May 10 19:18:37 2018 +0200

    fix: change unit test back to test for the setForcedArea method

commit af6d5c137ff57b13fbd8d6c9e097f7455f67cf7e
Author: Daniel Ruf <daniel@daniel-ruf.de>
Date:   Thu May 10 19:10:11 2018 +0200

    fix: just set the area if it is not set

commit 2fd7e5d84abcdea5306f2bd81dd44b86aaa970d7
Author: Daniel Ruf <daniel@daniel-ruf.de>
Date:   Thu May 10 16:55:35 2018 +0200

    fix: do not expect setForcedArea in unit tests for Magento\Theme\Test\Unit\Model\Design\Config\Validator

commit a1bf00c10d5fc01e5e592f38472b820141a47133
Author: Daniel Ruf <daniel@daniel-ruf.de>
Date:   Thu May 10 16:46:04 2018 +0200

    fix: do not set forced area in template, fixes magento#14968
@ihor-sviziev
Copy link
Contributor

FYI I created patch that can be applied on Magento 2.2.5. Just use following URL:
https://github.com/ihor-sviziev/magento2/commit/e4ec8adef586c615cda168175ad8950c701b0874.patch

@samuelgambs
Copy link

what a shame.... I am considering migrating to django / python

@ghermans
Copy link

Nice to see that you created a patch for it @ihor-sviziev 👍
However this issue should be resolved with a "hotfix" release (at least that is my personal opinion).

@hostep
Copy link
Contributor

hostep commented Jul 12, 2018

@ghermans : Magento 2 doesn't do hotfix releases unfortunately.
However, they've released an official patch over here: https://magento.com/tech-resources/download (search for MAGETWO-93036)

@raydvard
Copy link

raydvard commented Jul 17, 2018

As @EzzyEcom is saying, this problem is still in 2.2.5 ? on production server it's a hassle to modify core code and fix it nor using a hotfix.

@DanielRuf
Copy link
Contributor

As @EzzyEcom is saying, this problem is still in 2.2.5 ? on production server it's a hassle to modify core code and fix it nor using a hotfix.

Yes, it will be fixed in 2.2.6.

@zaheerbadi
Copy link

This happens even in 2.2.5. Some people have provided the solution but this is a patch to the core and it's not considered a permanent solution. Hope community fixed this in the new version and release it soon.

@DanielRuf
Copy link
Contributor

This happens even in 2.2.5. Some people have provided the solution but this is a patch to the core and it's not considered a permanent solution. Hope community fixed this in the new version and release it soon.

Please read the previous comments, this will be fixed in 2.2.6. The bot communicated a wrong date.

@boostify-pro
Copy link

Having same problem,
Magento 2.2.5

can't save "default page title" in Content > Design > Configuration

@DanielRuf
Copy link
Contributor

Having same problem,
Magento 2.2.5

can't save "default page title" in Content > Design > Configuration

Please just upvote at the top, do not comment I have this too. We are aware that it is not yet fixed but will be in 2.2.6.

@Aarhan
Copy link

Aarhan commented Jul 19, 2018

Hello Friends!

I was taking a look into this issue today and noticed that this error only seems prevalent when attempting to change the theme in the Global Configuration itself. If you change the theme in the Store View specifically it will be inherited by the Website and Global Configurations. I tested this with fresh installations of Magento 2.2.5 across multiple domains and was consistently able to change the theme by editing the Store Configuration specifically.

For example:

screen shot 2018-07-19 at 4 59 19 pm

In this case you would want to change the theme in the Store Configuration (First Row) which would then be inherited by the Website Configuration (Second Row) and Global Configuration (Third Row). I only experience this error when attempting to edit the Global Configuration (Third Row) directly.

(Please note that rows are in reference to the provided screenshot only.)

@DanielRuf
Copy link
Contributor

Hello Friends!

I was taking a look into this issue today and noticed that this error only seems prevalent when attempting to change the theme in the Global Configuration itself. If you change the theme in the Store View specifically it will be inherited by the Website and Global Configurations. I tested this with fresh installations of Magento 2.2.5 across multiple domains and was consistently able to change the theme by editing the Store Configuration specifically.

For example:

In this case you would want to change the theme in the Store Configuration (First Row) which would then be inherited by the Website Configuration (Second Row) and Global Configuration (Third Row). I only experience this error when attempting to edit the Global Configuration (Third Row) directly.

(Please note that rows are in reference to the provided screenshot only.)

This is all already known, please see the previous comments and the linked PR.

@magento magento locked as resolved and limited conversation to collaborators Jul 19, 2018
@DanielRuf
Copy link
Contributor

DanielRuf commented Jul 20, 2018

For those wo need a fix and can not update the entry in the database, see #14968 (comment)

You need the patch from https://magento.com/tech-resources/download#download2224 as this is probably in your vendor directory (composer based installs).

You can use composer-patches, also see https://support.magento.com/hc/en-us/articles/360005484154

And use this diff / patch:
https://github.com/magento/magento2/commit/7019a0a1392095185505ff3ca7b97dd3e9cb4ef2.diff

https://github.com/magento/magento2/commit/7019a0a1392095185505ff3ca7b97dd3e9cb4ef2.patch

@orozcodiaz orozcodiaz reopened this Sep 10, 2018
@hostep hostep closed this as completed Sep 10, 2018
@magento magento deleted a comment from hostep Sep 10, 2018
@miguelbalparda
Copy link
Contributor

Hi @oroskodias why did you delete @hostep comment?

@hostep
Copy link
Contributor

hostep commented Sep 12, 2018

He deleted his own comment as well, don't worry, it wasn't adding anything new to the discussion :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests