Skip to content

Commit 5e46973

Browse files
author
Magento CICD
authored
merge magento/develop into magento-qmt/MQE-121
2 parents 8963d57 + 100af87 commit 5e46973

File tree

29 files changed

+470
-114
lines changed

29 files changed

+470
-114
lines changed

app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public function getCalendarDateHtml()
8181
$yearStart = $this->_catalogProductOptionTypeDate->getYearStart();
8282
$yearEnd = $this->_catalogProductOptionTypeDate->getYearEnd();
8383

84+
$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
85+
/** Escape RTL characters which are present in some locales and corrupt formatting */
86+
$escapedDateFormat = preg_replace('/[^MmDdYy\/\.\-]/', '', $dateFormat);
8487
$calendar = $this->getLayout()->createBlock(
8588
\Magento\Framework\View\Element\Html\Date::class
8689
)->setId(
@@ -92,7 +95,7 @@ public function getCalendarDateHtml()
9295
)->setImage(
9396
$this->getViewFileUrl('Magento_Theme::calendar.png')
9497
)->setDateFormat(
95-
$this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT)
98+
$escapedDateFormat
9699
)->setValue(
97100
$value
98101
)->setYearsRange(

app/code/Magento/Catalog/Model/Product/Option/Type/Date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function prepareForCart()
155155

156156
if ($this->_dateExists()) {
157157
if ($this->useCalendar()) {
158-
$timestamp += (new \DateTime($value['date']))->getTimestamp();
158+
$timestamp += $this->_localeDate->date($value['date'], null, true, false)->getTimestamp();
159159
} else {
160160
$timestamp += mktime(0, 0, 0, $value['month'], $value['day'], $value['year']);
161161
}

app/code/Magento/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ class StockStatusBaseSelectProcessor implements BaseSelectProcessorInterface
2222
*/
2323
private $resource;
2424

25+
/**
26+
* @var \Magento\CatalogInventory\Api\StockConfigurationInterface
27+
*/
28+
private $stockConfig;
29+
2530
/**
2631
* @var \Magento\Indexer\Model\ResourceModel\FrontendResource
2732
*/
@@ -30,14 +35,18 @@ class StockStatusBaseSelectProcessor implements BaseSelectProcessorInterface
3035
/**
3136
* @param ResourceConnection $resource
3237
* @param null|\Magento\Indexer\Model\ResourceModel\FrontendResource $indexerStockFrontendResource
38+
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface|null $stockConfig
3339
*/
3440
public function __construct(
3541
ResourceConnection $resource,
36-
\Magento\Indexer\Model\ResourceModel\FrontendResource $indexerStockFrontendResource = null
42+
\Magento\Indexer\Model\ResourceModel\FrontendResource $indexerStockFrontendResource = null,
43+
\Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfig = null
3744
) {
3845
$this->resource = $resource;
3946
$this->indexerStockFrontendResource = $indexerStockFrontendResource ?: ObjectManager::getInstance()
4047
->get(\Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\FrontendResource::class);
48+
$this->stockConfig = $stockConfig ?: ObjectManager::getInstance()
49+
->get(\Magento\CatalogInventory\Api\StockConfigurationInterface::class);
4150
}
4251

4352
/**
@@ -50,13 +59,15 @@ public function process(Select $select)
5059
{
5160
$stockStatusTable = $this->indexerStockFrontendResource->getMainTable();
5261

53-
/** @var Select $select */
54-
$select->join(
55-
['stock' => $stockStatusTable],
56-
sprintf('stock.product_id = %s.entity_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
57-
[]
58-
)
59-
->where('stock.stock_status = ?', Stock::STOCK_IN_STOCK);
62+
if (!$this->stockConfig->isShowOutOfStock()) {
63+
/** @var Select $select */
64+
$select->join(
65+
['stock' => $stockStatusTable],
66+
sprintf('stock.product_id = %s.entity_id', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS),
67+
[]
68+
)->where('stock.stock_status = ?', Stock::STOCK_IN_STOCK);
69+
}
70+
6071
return $select;
6172
}
6273
}

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ public function createCollection()
237237
$conditions->collectValidatedAttributes($collection);
238238
$this->sqlBuilder->attachConditionToCollection($collection, $conditions);
239239

240+
/**
241+
* Prevent retrieval of duplicate records. This may occur when multiselect product attribute matches
242+
* several allowed values from condition simultaneously
243+
*/
244+
$collection->distinct(true);
245+
240246
return $collection;
241247
}
242248

app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
269269
'addStoreFilter',
270270
'setPageSize',
271271
'setCurPage',
272+
'distinct'
272273
])->disableOriginalConstructor()
273274
->getMock();
274275
$collection->expects($this->once())->method('setVisibility')
@@ -282,6 +283,7 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
282283
$collection->expects($this->once())->method('addStoreFilter')->willReturnSelf();
283284
$collection->expects($this->once())->method('setPageSize')->with($expectedPageSize)->willReturnSelf();
284285
$collection->expects($this->once())->method('setCurPage')->willReturnSelf();
286+
$collection->expects($this->once())->method('distinct')->willReturnSelf();
285287

286288
$this->collectionFactory->expects($this->once())->method('create')->willReturn($collection);
287289
$this->productsList->setData('conditions_encoded', 'some_serialized_conditions');

app/code/Magento/Deploy/Package/Processor/PreProcessor/Less.php

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,34 @@ private function hasOverrides(PackageFile $parentFile, Package $package)
127127
$parentFile->getPackage()->getPath(),
128128
$parentFile->getExtension()
129129
);
130-
$parentFiles = $this->collectFileMap($parentFile->getFileName(), $map);
131-
$currentPackageLessFiles = $package->getFilesByType('less');
132-
$currentPackageCssFiles = $package->getFilesByType('css');
133130
/** @var PackageFile[] $currentPackageFiles */
134-
$currentPackageFiles = array_merge($currentPackageLessFiles, $currentPackageCssFiles);
131+
$currentPackageFiles = array_merge($package->getFilesByType('less'), $package->getFilesByType('css'));
135132

136133
foreach ($currentPackageFiles as $file) {
137-
if (in_array($file->getDeployedFileName(), $parentFiles)) {
134+
if ($this->inParentFiles($file->getDeployedFileName(), $parentFile->getFileName(), $map)) {
138135
return true;
139136
}
140137
}
138+
return false;
139+
}
141140

142-
$intersections = array_intersect($parentFiles, array_keys($currentPackageFiles));
143-
if ($intersections) {
144-
return true;
141+
/**
142+
* @param string $fileName
143+
* @param string $parentFile
144+
* @param array $map
145+
* @return bool
146+
*/
147+
private function inParentFiles($fileName, $parentFile, $map)
148+
{
149+
if (isset($map[$parentFile])) {
150+
if (in_array($fileName, $map[$parentFile])) {
151+
return true;
152+
} else {
153+
foreach ($map[$parentFile] as $pFile) {
154+
return $this->inParentFiles($fileName, $pFile, $map);
155+
}
156+
}
145157
}
146-
147158
return false;
148159
}
149160

@@ -186,25 +197,6 @@ private function buildMap($filePath, $packagePath, $contentType)
186197
return $this->map;
187198
}
188199

189-
/**
190-
* Flatten map tree into simple array
191-
*
192-
* Original map file information structure in form of tree,
193-
* and to have checking of overridden files simpler we need to flatten that tree
194-
*
195-
* @param string $fileName
196-
* @param array $map
197-
* @return array
198-
*/
199-
private function collectFileMap($fileName, array $map)
200-
{
201-
$result = isset($map[$fileName]) ? $map[$fileName] : [];
202-
foreach ($result as $fName) {
203-
$result = array_merge($result, $this->collectFileMap($fName, $map));
204-
}
205-
return array_unique($result);
206-
}
207-
208200
/**
209201
* Return normalized path
210202
*

app/code/Magento/Deploy/Process/Queue.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,15 @@ private function assertAndExecute($name, array & $packages, array $packageJob)
187187
{
188188
/** @var Package $package */
189189
$package = $packageJob['package'];
190-
$parentPackagesDeployed = true;
191190
if ($package->getParent() && $package->getParent() !== $package) {
192-
if (!$this->isDeployed($package->getParent())) {
193-
$parentPackagesDeployed = false;
194-
} else {
195-
$dependencies = $packageJob['dependencies'];
196-
foreach ($dependencies as $parentPackage) {
197-
if (!$this->isDeployed($parentPackage)) {
198-
$parentPackagesDeployed = false;
199-
break;
200-
}
191+
foreach ($packageJob['dependencies'] as $dependencyName => $dependency) {
192+
if (!$this->isDeployed($dependency)) {
193+
$this->assertAndExecute($dependencyName, $packages, $packages[$dependencyName]);
201194
}
202195
}
203196
}
204-
if (
205-
$parentPackagesDeployed
206-
&& ($this->maxProcesses < 2 || (count($this->inProgress) < $this->maxProcesses))
207-
) {
197+
if (!$this->isDeployed($package)
198+
&& ($this->maxProcesses < 2 || (count($this->inProgress) < $this->maxProcesses))) {
208199
unset($packages[$name]);
209200
$this->execute($package);
210201
}

app/code/Magento/Deploy/Service/DeployRequireJsConfig.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Deploy\Service;
77

8+
use Magento\Framework\Locale\ResolverInterfaceFactory;
9+
use Magento\Framework\Locale\ResolverInterface;
810
use Magento\RequireJs\Model\FileManagerFactory;
911
use Magento\Framework\View\DesignInterfaceFactory;
1012
use Magento\Framework\View\Design\Theme\ListInterface;
@@ -46,6 +48,11 @@ class DeployRequireJsConfig
4648
*/
4749
private $requireJsConfigFactory;
4850

51+
/**
52+
* @var ResolverInterfaceFactory
53+
*/
54+
private $localeFactory;
55+
4956
/**
5057
* DeployRequireJsConfig constructor
5158
*
@@ -54,31 +61,40 @@ class DeployRequireJsConfig
5461
* @param RepositoryFactory $assetRepoFactory
5562
* @param FileManagerFactory $fileManagerFactory
5663
* @param ConfigFactory $requireJsConfigFactory
64+
* @param ResolverInterfaceFactory $localeFactory
5765
*/
5866
public function __construct(
5967
ListInterface $themeList,
6068
DesignInterfaceFactory $designFactory,
6169
RepositoryFactory $assetRepoFactory,
6270
FileManagerFactory $fileManagerFactory,
63-
ConfigFactory $requireJsConfigFactory
71+
ConfigFactory $requireJsConfigFactory,
72+
ResolverInterfaceFactory $localeFactory
6473
) {
6574
$this->themeList = $themeList;
6675
$this->designFactory = $designFactory;
6776
$this->assetRepoFactory = $assetRepoFactory;
6877
$this->fileManagerFactory = $fileManagerFactory;
6978
$this->requireJsConfigFactory = $requireJsConfigFactory;
79+
$this->localeFactory = $localeFactory;
7080
}
7181

7282
/**
7383
* @param string $areaCode
7484
* @param string $themePath
85+
* @param string $localeCode
7586
* @return bool true on success
7687
*/
77-
public function deploy($areaCode, $themePath)
88+
public function deploy($areaCode, $themePath, $localeCode)
7889
{
7990
/** @var \Magento\Framework\View\Design\ThemeInterface $theme */
8091
$theme = $this->themeList->getThemeByFullPath($areaCode . '/' . $themePath);
92+
/** @var \Magento\Theme\Model\View\Design $design */
8193
$design = $this->designFactory->create()->setDesignTheme($theme, $areaCode);
94+
/** @var ResolverInterface $locale */
95+
$locale = $this->localeFactory->create();
96+
$locale->setLocale($localeCode);
97+
$design->setLocale($locale);
8298

8399
$assetRepo = $this->assetRepoFactory->create(['design' => $design]);
84100
/** @var \Magento\RequireJs\Model\FileManager $fileManager */

app/code/Magento/Deploy/Service/DeployStaticContent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function deploy(array $options)
120120
]);
121121
foreach ($packages as $package) {
122122
if (!$package->isVirtual()) {
123-
$deployRjsConfig->deploy($package->getArea(), $package->getTheme());
123+
$deployRjsConfig->deploy($package->getArea(), $package->getTheme(), $package->getLocale());
124124
$deployI18n->deploy($package->getArea(), $package->getTheme(), $package->getLocale());
125125
$deployBundle->deploy($package->getArea(), $package->getTheme(), $package->getLocale());
126126
}

app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public function testAdd()
113113
public function testProcess()
114114
{
115115
$package = $this->getMock(Package::class, [], [], '', false);
116-
$package->expects($this->any())->method('getState')->willReturn(1);
117-
$package->expects($this->once())->method('getParent')->willReturn(null);
116+
$package->expects($this->any())->method('getState')->willReturn(0);
117+
$package->expects($this->exactly(2))->method('getParent')->willReturn(true);
118118
$package->expects($this->any())->method('getArea')->willReturn('area');
119119
$package->expects($this->any())->method('getPath')->willReturn('path');
120120
$package->expects($this->any())->method('getFiles')->willReturn([]);

0 commit comments

Comments
 (0)