Skip to content

Commit 75c9c84

Browse files
committed
AC-2391: Remove legacy variable resolver from email template processor
- cleanup setStrictMode()
1 parent 4cce3c3 commit 75c9c84

File tree

14 files changed

+10
-94
lines changed

14 files changed

+10
-94
lines changed

app/code/Magento/Email/Block/Adminhtml/Template/Preview.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function _toHtml()
6767
$template->setTemplateType($request->getParam('type'));
6868
$template->setTemplateText($request->getParam('text'));
6969
$template->setTemplateStyles($request->getParam('styles'));
70-
$template->setData('is_legacy', false);
70+
7171
}
7272

7373
\Magento\Framework\Profiler::start($this->profilerName);

app/code/Magento/Email/Model/AbstractTemplate.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -361,24 +361,11 @@ public function getProcessedTemplate(array $variables = [])
361361
$variables = $this->addEmailVariables($variables, $storeId);
362362
$processor->setVariables($variables);
363363

364-
// Type legacy id strict
365-
// db legacy true numeric false
366-
// db new false numeric true
367-
// filesystem false string false
368-
// preview false null true
369-
$isLegacy = $this->getData('is_legacy');
370-
$templateId = $this->getTemplateId();
371-
$previousStrictMode = $processor->setStrictMode(
372-
!$isLegacy && (is_numeric($templateId) || empty($templateId))
373-
);
374-
375364
try {
376365
$result = $processor->filter($this->getTemplateText());
377366
} catch (\Exception $e) {
378367
$this->cancelDesignConfig();
379368
throw new \LogicException(__($e->getMessage()), $e->getCode(), $e);
380-
} finally {
381-
$processor->setStrictMode($previousStrictMode);
382369
}
383370

384371
if ($isDesignApplied) {

app/code/Magento/Email/Model/Template.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,11 @@ public function getProcessedTemplateSubject(array $variables)
248248
$this->applyDesignConfig();
249249
$storeId = $this->getDesignConfig()->getStore();
250250

251-
$previousStrictMode = $processor->setStrictMode(
252-
!$this->getData('is_legacy') && is_numeric($this->getTemplateId())
253-
);
254-
255251
try {
256252
$processedResult = $processor->setStoreId($storeId)->filter(__($this->getTemplateSubject())->render());
257253
} catch (\Exception $e) {
258254
$this->cancelDesignConfig();
259255
throw new \Magento\Framework\Exception\MailException(__($e->getMessage()), $e);
260-
} finally {
261-
$processor->setStrictMode($previousStrictMode);
262256
}
263257

264258
$this->cancelDesignConfig();

app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
188188
'filter',
189189
'getStoreId',
190190
'getInlineCssFiles',
191-
'setStrictMode',
192191
]
193192
)
194193
->disableOriginalConstructor()
@@ -209,10 +208,6 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
209208
$filterTemplate->expects($this->any())
210209
->method('getStoreId')
211210
->willReturn($storeId);
212-
$filterTemplate->expects($this->exactly(2))
213-
->method('setStrictMode')
214-
->withConsecutive([$this->equalTo(true)], [$this->equalTo(false)])
215-
->willReturnOnConsecutiveCalls(false, true);
216211

217212
$expectedVariables['store'] = $this->store;
218213

@@ -271,7 +266,6 @@ public function testGetProcessedTemplateException()
271266
'filter',
272267
'getStoreId',
273268
'getInlineCssFiles',
274-
'setStrictMode',
275269
]
276270
)
277271
->disableOriginalConstructor()
@@ -288,10 +282,6 @@ public function testGetProcessedTemplateException()
288282
$filterTemplate->expects($this->any())
289283
->method('getStoreId')
290284
->willReturn(1);
291-
$filterTemplate->expects($this->exactly(2))
292-
->method('setStrictMode')
293-
->withConsecutive([$this->equalTo(false)], [$this->equalTo(true)])
294-
->willReturnOnConsecutiveCalls(true, false);
295285

296286
$model = $this->getModelMock(
297287
[

app/code/Magento/Email/Test/Unit/Model/TemplateTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,16 +523,12 @@ public function testGetProcessedTemplateSubject()
523523

524524
class_exists(Template::class, true);
525525
$filterTemplate = $this->getMockBuilder(\Magento\Framework\Filter\Template::class)
526-
->setMethods(['setVariables', 'setStoreId', 'filter', 'setStrictMode'])
526+
->setMethods(['setVariables', 'setStoreId', 'filter'])
527527
->disableOriginalConstructor()
528528
->getMock();
529529
$model->expects($this->once())
530530
->method('getTemplateFilter')
531531
->willReturn($filterTemplate);
532-
$filterTemplate->expects($this->exactly(2))
533-
->method('setStrictMode')
534-
->withConsecutive([$this->equalTo(true)], [$this->equalTo(false)])
535-
->willReturnOnConsecutiveCalls(false, true);
536532

537533
$model->expects($this->once())
538534
->method('applyDesignConfig');

app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ protected function loadTemplate(\Magento\Newsletter\Model\Template $template, $i
5656
$template->setTemplateType($queue->getNewsletterType());
5757
$template->setTemplateText($queue->getNewsletterText());
5858
$template->setTemplateStyles($queue->getNewsletterStyles());
59-
$template->setData('is_legacy', false);
6059

6160
return $this;
6261
}

app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ protected function _toHtml()
6565
$template->setTemplateType($previewData['type']);
6666
$template->setTemplateText($previewData['text']);
6767
$template->setTemplateStyles($previewData['styles']);
68-
$template->setData('is_legacy', false);
6968
}
7069

7170
\Magento\Framework\Profiler::start($this->profilerName);

app/code/Magento/Newsletter/Model/Template.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,7 @@ public function getProcessedTemplateSubject(array $variables)
203203
$filter = $this->getTemplateFilter();
204204
$filter->setVariables($variables);
205205

206-
$previousStrictMode = $filter->setStrictMode(
207-
!$this->getData('is_legacy') && is_numeric($this->getTemplateId())
208-
);
209-
$result = $filter->filter($this->getTemplateSubject());
210-
$filter->setStrictMode($previousStrictMode);
211-
212-
return $result;
206+
return $filter->filter($this->getTemplateSubject());
213207
}
214208

215209
/**

app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,6 @@ public function testGetProcessedTemplateSubject()
246246
->with($templateSubject)
247247
->willReturn($expectedResult);
248248

249-
$filterTemplate->expects($this->exactly(2))
250-
->method('setStrictMode')
251-
->withConsecutive([$this->equalTo(false)], [$this->equalTo(true)])
252-
->willReturnOnConsecutiveCalls(true, false);
253-
254249
$variables = ['key' => 'value'];
255250
$filterTemplate->expects($this->once())
256251
->method('setVariables')
@@ -287,8 +282,7 @@ class_exists(Filter::class, true);
287282
'setStoreId',
288283
'filter',
289284
'getStoreId',
290-
'getInlineCssFiles',
291-
'setStrictMode',
285+
'getInlineCssFiles'
292286
]
293287
)
294288
->disableOriginalConstructor()
@@ -309,11 +303,6 @@ class_exists(Filter::class, true);
309303
->method('getStoreId')
310304
->willReturn($storeId);
311305

312-
$filterTemplate->expects($this->exactly(2))
313-
->method('setStrictMode')
314-
->withConsecutive([$this->equalTo(true)], [$this->equalTo(false)])
315-
->willReturnOnConsecutiveCalls(false, true);
316-
317306
// The following block of code tests to ensure that the store id of the subscriber will be used, if the
318307
// 'subscriber' variable is set.
319308
$subscriber = $this->getMockBuilder(Subscriber::class)

dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,6 @@ public function testLegacyTemplateLoadedFromDbIsFilteredInLegacyMode()
405405

406406
$template = $this->objectManager->create(\Magento\Email\Model\Template::class);
407407
$templateData = [
408-
'is_legacy' => '1',
409408
'template_code' => 'some_unique_code',
410409
'template_type' => TemplateTypesInterface::TYPE_HTML,
411410
'template_text' => '{{var this.template_code}}'
@@ -439,7 +438,6 @@ public function testPreviewTemplateIsFilteredInStrictMode()
439438

440439
$template = $this->objectManager->create(\Magento\Email\Model\Template::class);
441440
$templateData = [
442-
'is_legacy' => '0',
443441
'template_code' => 'some_unique_code',
444442
'template_type' => TemplateTypesInterface::TYPE_HTML,
445443
'template_text' => '{{var this.template_code}}'

0 commit comments

Comments
 (0)