Skip to content

Commit e8eb0dc

Browse files
authored
Merge branch '2.4.4-develop' into AC-2461
2 parents 0b4ce27 + 3cf8909 commit e8eb0dc

File tree

21 files changed

+90
-553
lines changed

21 files changed

+90
-553
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: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,32 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
3131
/**
3232
* Default design area for emulation
3333
*/
34-
const DEFAULT_DESIGN_AREA = 'frontend';
34+
public const DEFAULT_DESIGN_AREA = 'frontend';
3535

3636
/**
3737
* Default path to email logo
3838
*/
39-
const DEFAULT_LOGO_FILE_ID = 'Magento_Email::logo_email.png';
39+
public const DEFAULT_LOGO_FILE_ID = 'Magento_Email::logo_email.png';
4040

4141
/**
4242
* Email logo url
4343
*/
44-
const XML_PATH_DESIGN_EMAIL_LOGO = 'design/email/logo';
44+
public const XML_PATH_DESIGN_EMAIL_LOGO = 'design/email/logo';
4545

4646
/**
4747
* Email logo alt text
4848
*/
49-
const XML_PATH_DESIGN_EMAIL_LOGO_ALT = 'design/email/logo_alt';
49+
public const XML_PATH_DESIGN_EMAIL_LOGO_ALT = 'design/email/logo_alt';
5050

5151
/**
5252
* Email logo width
5353
*/
54-
const XML_PATH_DESIGN_EMAIL_LOGO_WIDTH = 'design/email/logo_width';
54+
public const XML_PATH_DESIGN_EMAIL_LOGO_WIDTH = 'design/email/logo_width';
5555

5656
/**
5757
* Email logo height
5858
*/
59-
const XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT = 'design/email/logo_height';
59+
public const XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT = 'design/email/logo_height';
6060

6161
/**
6262
* Configuration of design package for template
@@ -144,8 +144,6 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
144144
protected $filesystem;
145145

146146
/**
147-
* Scope config
148-
*
149147
* @var \Magento\Framework\App\Config\ScopeConfigInterface
150148
*/
151149
protected $scopeConfig;
@@ -361,24 +359,11 @@ public function getProcessedTemplate(array $variables = [])
361359
$variables = $this->addEmailVariables($variables, $storeId);
362360
$processor->setVariables($variables);
363361

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-
375362
try {
376363
$result = $processor->filter($this->getTemplateText());
377364
} catch (\Exception $e) {
378365
$this->cancelDesignConfig();
379366
throw new \LogicException(__($e->getMessage()), $e->getCode(), $e);
380-
} finally {
381-
$processor->setStrictMode($previousStrictMode);
382367
}
383368

384369
if ($isDesignApplied) {
@@ -468,6 +453,8 @@ protected function addEmailVariables($variables, $storeId)
468453
if (!isset($variables['store'])) {
469454
$variables['store'] = $store;
470455
}
456+
$storeAddress = $variables['store']->getFormattedAddress();
457+
$variables['store']->setData('formatted_address', $storeAddress);
471458
if (!isset($variables['store']['frontend_name'])) {
472459
$variables['store']['frontend_name'] = $store->getFrontendName();
473460
}

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ class Template extends AbstractTemplate implements \Magento\Framework\Mail\Templ
4545
* @deprecated
4646
* @see \Magento\Email\Model\Transport::XML_PATH_SENDING_SET_RETURN_PATH
4747
*/
48-
const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path';
48+
public const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path';
4949

5050
/**
5151
* Configuration path for custom Return-Path email
5252
* @deprecated
5353
* @see \Magento\Email\Model\Transport::XML_PATH_SENDING_RETURN_PATH_EMAIL
5454
*/
55-
const XML_PATH_SENDING_RETURN_PATH_EMAIL = 'system/smtp/return_path_email';
55+
public const XML_PATH_SENDING_RETURN_PATH_EMAIL = 'system/smtp/return_path_email';
5656

5757
/**
5858
* Config path to mail sending setting that shows if email communications are disabled
5959
* @deprecated
6060
* @see https://github.com/magento/magento2/issues/5988
6161
*/
62-
const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable';
62+
public const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable';
6363

6464
/**
6565
* BCC list
@@ -69,8 +69,6 @@ class Template extends AbstractTemplate implements \Magento\Framework\Mail\Templ
6969
protected $_bcc = [];
7070

7171
/**
72-
* Return path
73-
*
7472
* @var string
7573
*/
7674
protected $_returnPath = '';
@@ -248,17 +246,11 @@ public function getProcessedTemplateSubject(array $variables)
248246
$this->applyDesignConfig();
249247
$storeId = $this->getDesignConfig()->getStore();
250248

251-
$previousStrictMode = $processor->setStrictMode(
252-
!$this->getData('is_legacy') && is_numeric($this->getTemplateId())
253-
);
254-
255249
try {
256250
$processedResult = $processor->setStoreId($storeId)->filter(__($this->getTemplateSubject())->render());
257251
} catch (\Exception $e) {
258252
$this->cancelDesignConfig();
259253
throw new \Magento\Framework\Exception\MailException(__($e->getMessage()), $e);
260-
} finally {
261-
$processor->setStrictMode($previousStrictMode);
262254
}
263255

264256
$this->cancelDesignConfig();

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function setUp(): void
9797
->getMockForAbstractClass();
9898

9999
$this->store = $this->getMockBuilder(Store::class)
100-
->setMethods(['getFrontendName', 'getId'])
100+
->setMethods(['getFrontendName', 'getId', 'getFormattedAddress'])
101101
->disableOriginalConstructor()
102102
->getMock();
103103
$this->store->expects($this->any())
@@ -106,6 +106,9 @@ protected function setUp(): void
106106
$this->store->expects($this->any())
107107
->method('getFrontendName')
108108
->willReturn('storeId');
109+
$this->store->expects($this->any())
110+
->method('getFormattedAddress')
111+
->willReturn("Test Store\n Street 1");
109112
$this->storeManager->expects($this->any())
110113
->method('getStore')
111114
->willReturn($this->store);
@@ -188,7 +191,6 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
188191
'filter',
189192
'getStoreId',
190193
'getInlineCssFiles',
191-
'setStrictMode',
192194
]
193195
)
194196
->disableOriginalConstructor()
@@ -209,10 +211,6 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
209211
$filterTemplate->expects($this->any())
210212
->method('getStoreId')
211213
->willReturn($storeId);
212-
$filterTemplate->expects($this->exactly(2))
213-
->method('setStrictMode')
214-
->withConsecutive([$this->equalTo(true)], [$this->equalTo(false)])
215-
->willReturnOnConsecutiveCalls(false, true);
216214

217215
$expectedVariables['store'] = $this->store;
218216

@@ -271,7 +269,6 @@ public function testGetProcessedTemplateException()
271269
'filter',
272270
'getStoreId',
273271
'getInlineCssFiles',
274-
'setStrictMode',
275272
]
276273
)
277274
->disableOriginalConstructor()
@@ -288,10 +285,6 @@ public function testGetProcessedTemplateException()
288285
$filterTemplate->expects($this->any())
289286
->method('getStoreId')
290287
->willReturn(1);
291-
$filterTemplate->expects($this->exactly(2))
292-
->method('setStrictMode')
293-
->withConsecutive([$this->equalTo(false)], [$this->equalTo(true)])
294-
->willReturnOnConsecutiveCalls(true, false);
295288

296289
$model = $this->getModelMock(
297290
[

app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use Magento\Framework\Filter\DirectiveProcessor\IfDirective;
2727
use Magento\Framework\Filter\DirectiveProcessor\LegacyDirective;
2828
use Magento\Framework\Filter\DirectiveProcessor\TemplateDirective;
29-
use Magento\Framework\Filter\VariableResolver\StrategyResolver;
29+
use Magento\Framework\Filter\VariableResolver\StrictResolver;
3030
use Magento\Framework\Stdlib\StringUtils;
3131
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
3232
use Magento\Framework\View\Asset\ContentProcessorInterface;
@@ -137,7 +137,7 @@ class FilterTest extends TestCase
137137
private $pubDirectoryRead;
138138

139139
/**
140-
* @var MockObject|StrategyResolver
140+
* @var MockObject|StrictResolver
141141
*/
142142
private $variableResolver;
143143

@@ -222,7 +222,7 @@ protected function setUp(): void
222222
->disableOriginalConstructor()
223223
->getMock();
224224
$this->variableResolver =
225-
$this->getMockBuilder(StrategyResolver::class)
225+
$this->getMockBuilder(StrictResolver::class)
226226
->disableOriginalConstructor()
227227
->getMock();
228228

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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class Preview extends \Magento\Newsletter\Block\Adminhtml\Template\Preview
1515
{
1616
/**
17-
* {@inheritdoc}
17+
* @var string
1818
*/
1919
protected $profilerName = "newsletter_queue_proccessing";
2020

@@ -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: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ class Template extends \Magento\Email\Model\AbstractTemplate
4040
/**
4141
* Mail object
4242
*
43-
* @deprecated 100.3.0 Unused property
43+
* @var \Zend_Mail
4444
*
45+
* @deprecated 100.3.0 Unused property
4546
*/
4647
protected $_mail;
4748

@@ -60,8 +61,6 @@ class Template extends \Magento\Email\Model\AbstractTemplate
6061
protected $_request;
6162

6263
/**
63-
* Filter factory
64-
*
6564
* @var \Magento\Newsletter\Model\Template\FilterFactory
6665
*/
6766
protected $_filterFactory;
@@ -203,13 +202,7 @@ public function getProcessedTemplateSubject(array $variables)
203202
$filter = $this->getTemplateFilter();
204203
$filter->setVariables($variables);
205204

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;
205+
return $filter->filter($this->getTemplateSubject());
213206
}
214207

215208
/**

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected function setUp(): void
136136
->getMockForAbstractClass();
137137

138138
$this->storeMock = $this->getMockBuilder(Store::class)
139-
->setMethods(['getFrontendName', 'getId'])
139+
->setMethods(['getFrontendName', 'getId', 'getFormattedAddress'])
140140
->disableOriginalConstructor()
141141
->getMock();
142142

@@ -148,6 +148,10 @@ protected function setUp(): void
148148
->method('getFrontendName')
149149
->willReturn('storeId');
150150

151+
$this->storeMock->expects($this->any())
152+
->method('getFormattedAddress')
153+
->willReturn("Test Store\n Street 1");
154+
151155
$this->storeManagerMock->expects($this->any())
152156
->method('getStore')
153157
->willReturn($this->storeMock);
@@ -246,11 +250,6 @@ public function testGetProcessedTemplateSubject()
246250
->with($templateSubject)
247251
->willReturn($expectedResult);
248252

249-
$filterTemplate->expects($this->exactly(2))
250-
->method('setStrictMode')
251-
->withConsecutive([$this->equalTo(false)], [$this->equalTo(true)])
252-
->willReturnOnConsecutiveCalls(true, false);
253-
254253
$variables = ['key' => 'value'];
255254
$filterTemplate->expects($this->once())
256255
->method('setVariables')
@@ -287,8 +286,7 @@ class_exists(Filter::class, true);
287286
'setStoreId',
288287
'filter',
289288
'getStoreId',
290-
'getInlineCssFiles',
291-
'setStrictMode',
289+
'getInlineCssFiles'
292290
]
293291
)
294292
->disableOriginalConstructor()
@@ -309,11 +307,6 @@ class_exists(Filter::class, true);
309307
->method('getStoreId')
310308
->willReturn($storeId);
311309

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

0 commit comments

Comments
 (0)