Skip to content

Commit f4cf8c4

Browse files
author
Stanislav Idolov
committed
Merge remote-tracking branch 'mainline/2.3-develop' into magento-engcom/memory-leak-calculation-improvement
2 parents bfb6c8f + 2635bd8 commit f4cf8c4

File tree

86 files changed

+3839
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3839
-656
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[![Open Source Helpers](https://www.codetriage.com/magento/magento2/badges/users.svg)](https://www.codetriage.com/magento/magento2)
22
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
33
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.svg)](https://crowdin.com/project/magento-2)
4-
<h2>Welcome</h2>
4+
5+
## Welcome
56
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.
67

78
## Magento System Requirements
@@ -30,7 +31,7 @@ To suggest documentation improvements, click [here][4].
3031
[4]: https://devdocs.magento.com
3132

3233
<h3>Community Maintainers</h3>
33-
The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks these Community Maintainers for their valuable contributions.
34+
The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks to these Community Maintainers for their valuable contributions.
3435

3536
<a href="https://magento.com/magento-contributors#maintainers">
3637
<img src="https://raw.githubusercontent.com/wiki/magento/magento2/images/maintainers.png"/>

app/code/Magento/CustomerGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ input CustomerInput {
6161
middlename: String @doc(description: "The customer's middle name")
6262
lastname: String @doc(description: "The customer's family name")
6363
suffix: String @doc(description: "A value such as Sr., Jr., or III")
64-
email: String! @doc(description: "The customer's email address. Required")
64+
email: String @doc(description: "The customer's email address. Required for customer creation")
6565
dob: String @doc(description: "Deprecated: Use `date_of_birth` instead")
6666
date_of_birth: String @doc(description: "The customer's date of birth")
6767
taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)")

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

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,20 @@ class Filter extends \Magento\Framework\Filter\Template
167167
protected $configVariables;
168168

169169
/**
170-
* @var \Magento\Email\Model\Template\Css\Processor
170+
* @var Css\Processor
171171
*/
172172
private $cssProcessor;
173173

174174
/**
175-
* @var ReadInterface
175+
* @var Filesystem
176176
*/
177177
private $pubDirectory;
178178

179+
/**
180+
* @var \Magento\Framework\Filesystem\Directory\Read
181+
*/
182+
private $pubDirectoryRead;
183+
179184
/**
180185
* @param \Magento\Framework\Stdlib\StringUtils $string
181186
* @param \Psr\Log\LoggerInterface $logger
@@ -192,9 +197,10 @@ class Filter extends \Magento\Framework\Filter\Template
192197
* @param \Magento\Variable\Model\Source\Variables $configVariables
193198
* @param array $variables
194199
* @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner|null $cssInliner
195-
*
196200
* @param array $directiveProcessors
197201
* @param VariableResolverInterface|null $variableResolver
202+
* @param Css\Processor|null $cssProcessor
203+
* @param Filesystem|null $pubDirectory
198204
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
199205
*/
200206
public function __construct(
@@ -214,7 +220,9 @@ public function __construct(
214220
$variables = [],
215221
\Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner = null,
216222
array $directiveProcessors = [],
217-
VariableResolverInterface $variableResolver = null
223+
VariableResolverInterface $variableResolver = null,
224+
Css\Processor $cssProcessor = null,
225+
Filesystem $pubDirectory = null
218226
) {
219227
$this->_escaper = $escaper;
220228
$this->_assetRepo = $assetRepo;
@@ -230,6 +238,10 @@ public function __construct(
230238
$this->emogrifier = $emogrifier;
231239
$this->cssInliner = $cssInliner ?: \Magento\Framework\App\ObjectManager::getInstance()
232240
->get(\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class);
241+
$this->cssProcessor = $cssProcessor ?: ObjectManager::getInstance()
242+
->get(Css\Processor::class);
243+
$this->pubDirectory = $pubDirectory ?: ObjectManager::getInstance()
244+
->get(Filesystem::class);
233245
$this->configVariables = $configVariables;
234246
parent::__construct($string, $variables, $directiveProcessors, $variableResolver);
235247
}
@@ -327,32 +339,14 @@ public function setDesignParams(array $designParams)
327339
}
328340

329341
/**
330-
* Get CSS processor
331-
*
332-
* @deprecated 100.1.2
333-
* @return Css\Processor
334-
*/
335-
private function getCssProcessor()
336-
{
337-
if (!$this->cssProcessor) {
338-
$this->cssProcessor = ObjectManager::getInstance()->get(Css\Processor::class);
339-
}
340-
return $this->cssProcessor;
341-
}
342-
343-
/**
344-
* Get pub directory
342+
* Sets pub directory
345343
*
346-
* @deprecated 100.1.2
347344
* @param string $dirType
348-
* @return ReadInterface
345+
* @return void
349346
*/
350-
private function getPubDirectory($dirType)
347+
private function setPubDirectory($dirType)
351348
{
352-
if (!$this->pubDirectory) {
353-
$this->pubDirectory = ObjectManager::getInstance()->get(Filesystem::class)->getDirectoryRead($dirType);
354-
}
355-
return $this->pubDirectory;
349+
$this->pubDirectoryRead = $this->pubDirectory->getDirectoryRead($dirType);
356350
}
357351

358352
/**
@@ -856,7 +850,7 @@ public function cssDirective($construction)
856850
return '/* ' . __('"file" parameter must be specified') . ' */';
857851
}
858852

859-
$css = $this->getCssProcessor()->process(
853+
$css = $this->cssProcessor->process(
860854
$this->getCssFilesContent([$params['file']])
861855
);
862856

@@ -959,9 +953,9 @@ public function getCssFilesContent(array $files)
959953
try {
960954
foreach ($files as $file) {
961955
$asset = $this->_assetRepo->createAsset($file, $designParams);
962-
$pubDirectory = $this->getPubDirectory($asset->getContext()->getBaseDirType());
963-
if ($pubDirectory->isExist($asset->getPath())) {
964-
$css .= $pubDirectory->readFile($asset->getPath());
956+
$this->setPubDirectory($asset->getContext()->getBaseDirType());
957+
if ($this->pubDirectoryRead->isExist($asset->getPath())) {
958+
$css .= $this->pubDirectoryRead->readFile($asset->getPath());
965959
} else {
966960
$css .= $asset->getContent();
967961
}
@@ -991,7 +985,7 @@ public function applyInlineCss($html)
991985
$cssToInline = $this->getCssFilesContent(
992986
$this->getInlineCssFiles()
993987
);
994-
$cssToInline = $this->getCssProcessor()->process($cssToInline);
988+
$cssToInline = $this->cssProcessor->process($cssToInline);
995989

996990
// Only run Emogrify if HTML and CSS contain content
997991
if ($html && $cssToInline) {

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

Lines changed: 75 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
7+
declare(strict_types=1);
8+
69
namespace Magento\Email\Test\Unit\Model\Template;
710

811
use Magento\Email\Model\Template\Css\Processor;
@@ -14,6 +17,7 @@
1417

1518
/**
1619
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
20+
* @SuppressWarnings(PHPMD.TooManyFields)
1721
*/
1822
class FilterTest extends \PHPUnit\Framework\TestCase
1923
{
@@ -92,6 +96,31 @@ class FilterTest extends \PHPUnit\Framework\TestCase
9296
*/
9397
private $cssInliner;
9498

99+
/**
100+
* @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Email\Model\Template\Css\Processor
101+
*/
102+
private $cssProcessor;
103+
104+
/**
105+
* @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Framework\Filesystem
106+
*/
107+
private $pubDirectory;
108+
109+
/**
110+
* @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Framework\Filesystem\Directory\Read
111+
*/
112+
private $pubDirectoryRead;
113+
114+
/**
115+
* @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Framework\Filter\VariableResolver\StrategyResolver
116+
*/
117+
private $variableResolver;
118+
119+
/**
120+
* @var array
121+
*/
122+
private $directiveProcessors;
123+
95124
protected function setUp()
96125
{
97126
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -147,6 +176,41 @@ protected function setUp()
147176
$this->cssInliner = $this->objectManager->getObject(
148177
\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class
149178
);
179+
180+
$this->cssProcessor = $this->getMockBuilder(\Magento\Email\Model\Template\Css\Processor::class)
181+
->disableOriginalConstructor()
182+
->getMock();
183+
184+
$this->pubDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
185+
->disableOriginalConstructor()
186+
->getMock();
187+
188+
$this->pubDirectoryRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Read::class)
189+
->disableOriginalConstructor()
190+
->getMock();
191+
$this->variableResolver =
192+
$this->getMockBuilder(\Magento\Framework\Filter\VariableResolver\StrategyResolver::class)
193+
->disableOriginalConstructor()
194+
->getMock();
195+
196+
$this->directiveProcessors = [
197+
'depend' =>
198+
$this->getMockBuilder(\Magento\Framework\Filter\DirectiveProcessor\DependDirective::class)
199+
->disableOriginalConstructor()
200+
->getMock(),
201+
'if' =>
202+
$this->getMockBuilder(\Magento\Framework\Filter\DirectiveProcessor\IfDirective::class)
203+
->disableOriginalConstructor()
204+
->getMock(),
205+
'template' =>
206+
$this->getMockBuilder(\Magento\Framework\Filter\DirectiveProcessor\TemplateDirective::class)
207+
->disableOriginalConstructor()
208+
->getMock(),
209+
'legacy' =>
210+
$this->getMockBuilder(\Magento\Framework\Filter\DirectiveProcessor\LegacyDirective::class)
211+
->disableOriginalConstructor()
212+
->getMock(),
213+
];
150214
}
151215

152216
/**
@@ -173,6 +237,10 @@ protected function getModel($mockedMethods = null)
173237
$this->configVariables,
174238
[],
175239
$this->cssInliner,
240+
$this->directiveProcessors,
241+
$this->variableResolver,
242+
$this->cssProcessor,
243+
$this->pubDirectory
176244
]
177245
)
178246
->setMethods($mockedMethods)
@@ -252,17 +320,16 @@ public function testGetCssFilesContent()
252320
->with($file, $designParams)
253321
->willReturn($asset);
254322

255-
$pubDirectory = $this->getMockBuilder(ReadInterface::class)
256-
->getMockForAbstractClass();
257-
$reflectionClass = new \ReflectionClass(Filter::class);
258-
$reflectionProperty = $reflectionClass->getProperty('pubDirectory');
259-
$reflectionProperty->setAccessible(true);
260-
$reflectionProperty->setValue($filter, $pubDirectory);
261-
$pubDirectory->expects($this->once())
323+
$this->pubDirectory
324+
->expects($this->once())
325+
->method('getDirectoryRead')
326+
->willReturn($this->pubDirectoryRead);
327+
328+
$this->pubDirectoryRead->expects($this->once())
262329
->method('isExist')
263330
->with($path . DIRECTORY_SEPARATOR . $file)
264331
->willReturn(true);
265-
$pubDirectory->expects($this->once())
332+
$this->pubDirectoryRead->expects($this->once())
266333
->method('readFile')
267334
->with($path . DIRECTORY_SEPARATOR . $file)
268335
->willReturn($css);
@@ -319,43 +386,6 @@ public function testApplyInlineCssThrowsExceptionWhenDesignParamsNotSet()
319386
$filter->applyInlineCss('test');
320387
}
321388

322-
/**
323-
* Ensure that after filter callbacks are reset after exception is thrown during filtering
324-
*/
325-
public function testAfterFilterCallbackGetsResetWhenExceptionTriggered()
326-
{
327-
$value = '{{var random_var}}';
328-
$exception = new \Exception('Test exception');
329-
$exceptionResult = sprintf(__('Error filtering template: %s'), $exception->getMessage());
330-
331-
$this->appState->expects($this->once())
332-
->method('getMode')
333-
->will($this->returnValue(\Magento\Framework\App\State::MODE_DEVELOPER));
334-
$this->logger->expects($this->once())
335-
->method('critical')
336-
->with($exception);
337-
338-
$filter = $this->getModel(['varDirective', 'resetAfterFilterCallbacks']);
339-
$filter->expects($this->once())
340-
->method('varDirective')
341-
->will($this->throwException($exception));
342-
343-
// Callbacks must be reset after exception is thrown
344-
$filter->expects($this->once())
345-
->method('resetAfterFilterCallbacks');
346-
347-
// Build arbitrary object to pass into the addAfterFilterCallback method
348-
$callbackObject = $this->getMockBuilder('stdObject')
349-
->setMethods(['afterFilterCallbackMethod'])
350-
->getMock();
351-
// Callback should never run due to exception happening during filtering
352-
$callbackObject->expects($this->never())
353-
->method('afterFilterCallbackMethod');
354-
$filter->addAfterFilterCallback([$callbackObject, 'afterFilterCallbackMethod']);
355-
356-
$this->assertEquals($exceptionResult, $filter->filter($value));
357-
}
358-
359389
public function testConfigDirectiveAvailable()
360390
{
361391
$path = "web/unsecure/base_url";

0 commit comments

Comments
 (0)