From 0ae1230c4bbe985f66929ed234835137e64664c9 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Thu, 10 May 2018 16:46:04 +0200 Subject: [PATCH 1/4] fix: do not set forced area in template, fixes #14968 --- app/code/Magento/Theme/Model/Design/Config/Validator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Theme/Model/Design/Config/Validator.php b/app/code/Magento/Theme/Model/Design/Config/Validator.php index 6d2f9d65a3c0b..d0fed000d1390 100644 --- a/app/code/Magento/Theme/Model/Design/Config/Validator.php +++ b/app/code/Magento/Theme/Model/Design/Config/Validator.php @@ -114,7 +114,6 @@ private function getTemplateText($templateId, DesignConfigInterface $designConfi if (is_numeric($templateId)) { $template->load($templateId); } else { - $template->setForcedArea($templateId); $template->loadDefault($templateId); } $text = $template->getTemplateText(); From 3df51d4c294dda946d78ba25b9aef693cb813a0a Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Thu, 10 May 2018 16:55:35 +0200 Subject: [PATCH 2/4] fix: do not expect setForcedArea in unit tests for Magento\Theme\Test\Unit\Model\Design\Config\Validator --- .../Theme/Test/Unit/Model/Design/Config/ValidatorTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Config/ValidatorTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Config/ValidatorTest.php index df5b5dc902c25..4ff69801e04f0 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Config/ValidatorTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Config/ValidatorTest.php @@ -49,7 +49,6 @@ public function setUp() ->setMethods( [ 'emulateDesign', - 'setForcedArea', 'loadDefault', 'getTemplateText', 'revertDesign', @@ -77,7 +76,6 @@ public function testGetDefaultTemplateTextDefaultScope() $this->templateFactory->expects($this->once())->method('create'); $this->designConfig->expects($this->any())->method('getScope')->willReturn('default'); $this->template->expects($this->once())->method('emulateDesign'); - $this->template->expects($this->once())->method('setForcedArea')->with($templateId); $this->template->expects($this->once())->method('loadDefault')->with($templateId); $this->template->expects($this->once())->method('getTemplateText'); $this->template->expects($this->once())->method('revertDesign'); From 0dec988872e175e568c2bf4bb29548ab7a4698e5 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Thu, 10 May 2018 19:10:11 +0200 Subject: [PATCH 3/4] fix: just set the area if it is not set --- app/code/Magento/Email/Model/AbstractTemplate.php | 5 ++--- app/code/Magento/Theme/Model/Design/Config/Validator.php | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Email/Model/AbstractTemplate.php b/app/code/Magento/Email/Model/AbstractTemplate.php index fa9d28074bf85..81e993fad76df 100644 --- a/app/code/Magento/Email/Model/AbstractTemplate.php +++ b/app/code/Magento/Email/Model/AbstractTemplate.php @@ -534,10 +534,9 @@ protected function cancelDesignConfig() */ public function setForcedArea($templateId) { - if ($this->area) { - throw new \LogicException(__('Area is already set')); + if (!isset($this->area)) { + $this->area = $this->emailConfig->getTemplateArea($templateId); } - $this->area = $this->emailConfig->getTemplateArea($templateId); return $this; } diff --git a/app/code/Magento/Theme/Model/Design/Config/Validator.php b/app/code/Magento/Theme/Model/Design/Config/Validator.php index d0fed000d1390..6d2f9d65a3c0b 100644 --- a/app/code/Magento/Theme/Model/Design/Config/Validator.php +++ b/app/code/Magento/Theme/Model/Design/Config/Validator.php @@ -114,6 +114,7 @@ private function getTemplateText($templateId, DesignConfigInterface $designConfi if (is_numeric($templateId)) { $template->load($templateId); } else { + $template->setForcedArea($templateId); $template->loadDefault($templateId); } $text = $template->getTemplateText(); From d92b679e48da825813bfaff51e631236a2bbc73a Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Thu, 10 May 2018 19:18:37 +0200 Subject: [PATCH 4/4] fix: change unit test back to test for the setForcedArea method --- .../Theme/Test/Unit/Model/Design/Config/ValidatorTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Theme/Test/Unit/Model/Design/Config/ValidatorTest.php b/app/code/Magento/Theme/Test/Unit/Model/Design/Config/ValidatorTest.php index 4ff69801e04f0..df5b5dc902c25 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/Design/Config/ValidatorTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/Design/Config/ValidatorTest.php @@ -49,6 +49,7 @@ public function setUp() ->setMethods( [ 'emulateDesign', + 'setForcedArea', 'loadDefault', 'getTemplateText', 'revertDesign', @@ -76,6 +77,7 @@ public function testGetDefaultTemplateTextDefaultScope() $this->templateFactory->expects($this->once())->method('create'); $this->designConfig->expects($this->any())->method('getScope')->willReturn('default'); $this->template->expects($this->once())->method('emulateDesign'); + $this->template->expects($this->once())->method('setForcedArea')->with($templateId); $this->template->expects($this->once())->method('loadDefault')->with($templateId); $this->template->expects($this->once())->method('getTemplateText'); $this->template->expects($this->once())->method('revertDesign');