Skip to content

Commit 36ea828

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop latest changes
Accepted Community Pull Requests: - #25546: Prevent saving upload media files in root directory (by @kenboy) - #25629: Reverted PR 25022 (by @drpayyne) - #25547: Fix exception handling and cover with unit tests the GetById media asset command (by @coderimus) - #25613: Navigation menu 4th level/category does not appear consistently #25589 (by @fabriciosobral) - #25355: M2C-2205 Move LESS styling files (by @ptylek) - #25638: Add indexer console command output (by @brosenberger) - #25623: #25043 - Since 2.3.3 Store logo automatic resize on mobile/smaller displays does not respect aspect ratio (by @fabriciosobral) Fixed GitHub Issues: - #24840: Drop down icon invisible for a moment if not select value and click on Load Template (reported by @hasim32) has been fixed in #25629 by @drpayyne in 2.3-develop branch Related commits: 1. 16aabf7 - #25589: Navigation menu 4th level/category does not appear consistently (reported by @dbabaev) has been fixed in #25613 by @fabriciosobral in 2.3-develop branch Related commits: 1. 16fa4c4 - #25276: Magento_Contact module MUST NOT include any design-level LESS styling (reported by @danemacmillan) has been fixed in #25355 by @ptylek in 2.3-develop branch Related commits: 1. 42d2163 2. 2c6ad75 - #25043: Since 2.3.3 Store logo automatic resize on mobile/smaller displays does not respect aspect ratio (reported by @gwharton) has been fixed in #25623 by @fabriciosobral in 2.3-develop branch Related commits: 1. d0167a0
2 parents 2b9ab21 + 6ce0880 commit 36ea828

File tree

15 files changed

+591
-81
lines changed

15 files changed

+591
-81
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,9 +2035,9 @@ protected function _saveProductTierPrices(array $tierPriceData)
20352035
protected function _getUploader()
20362036
{
20372037
if ($this->_fileUploader === null) {
2038-
$this->_fileUploader = $this->_uploaderFactory->create();
2038+
$fileUploader = $this->_uploaderFactory->create();
20392039

2040-
$this->_fileUploader->init();
2040+
$fileUploader->init();
20412041

20422042
$dirConfig = DirectoryList::getDefaultConfig();
20432043
$dirAddon = $dirConfig[DirectoryList::MEDIA][DirectoryList::PATH];
@@ -2048,7 +2048,7 @@ protected function _getUploader()
20482048
$tmpPath = $dirAddon . '/' . $this->_mediaDirectory->getRelativePath('import');
20492049
}
20502050

2051-
if (!$this->_fileUploader->setTmpDir($tmpPath)) {
2051+
if (!$fileUploader->setTmpDir($tmpPath)) {
20522052
throw new LocalizedException(
20532053
__('File directory \'%1\' is not readable.', $tmpPath)
20542054
);
@@ -2057,11 +2057,13 @@ protected function _getUploader()
20572057
$destinationPath = $dirAddon . '/' . $this->_mediaDirectory->getRelativePath($destinationDir);
20582058

20592059
$this->_mediaDirectory->create($destinationPath);
2060-
if (!$this->_fileUploader->setDestDir($destinationPath)) {
2060+
if (!$fileUploader->setDestDir($destinationPath)) {
20612061
throw new LocalizedException(
20622062
__('File directory \'%1\' is not writable.', $destinationPath)
20632063
);
20642064
}
2065+
2066+
$this->_fileUploader = $fileUploader;
20652067
}
20662068
return $this->_fileUploader;
20672069
}

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/ProductTest.php

Lines changed: 111 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,11 @@ protected function setUp()
284284
->getMock();
285285
$this->storeResolver =
286286
$this->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Product\StoreResolver::class)
287-
->setMethods([
288-
'getStoreCodeToId',
289-
])
287+
->setMethods(
288+
[
289+
'getStoreCodeToId',
290+
]
291+
)
290292
->disableOriginalConstructor()
291293
->getMock();
292294
$this->skuProcessor =
@@ -410,7 +412,7 @@ protected function _objectConstructor()
410412
$this->_filesystem->expects($this->once())
411413
->method('getDirectoryWrite')
412414
->with(DirectoryList::ROOT)
413-
->will($this->returnValue(self::MEDIA_DIRECTORY));
415+
->willReturn($this->_mediaDirectory);
414416

415417
$this->validator->expects($this->any())->method('init');
416418
return $this;
@@ -596,9 +598,13 @@ public function testGetMultipleValueSeparatorDefault()
596598
public function testGetMultipleValueSeparatorFromParameters()
597599
{
598600
$expectedSeparator = 'value';
599-
$this->setPropertyValue($this->importProduct, '_parameters', [
600-
\Magento\ImportExport\Model\Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR => $expectedSeparator,
601-
]);
601+
$this->setPropertyValue(
602+
$this->importProduct,
603+
'_parameters',
604+
[
605+
\Magento\ImportExport\Model\Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR => $expectedSeparator,
606+
]
607+
);
602608

603609
$this->assertEquals(
604610
$expectedSeparator,
@@ -618,9 +624,13 @@ public function testGetEmptyAttributeValueConstantDefault()
618624
public function testGetEmptyAttributeValueConstantFromParameters()
619625
{
620626
$expectedSeparator = '__EMPTY__VALUE__TEST__';
621-
$this->setPropertyValue($this->importProduct, '_parameters', [
622-
\Magento\ImportExport\Model\Import::FIELD_EMPTY_ATTRIBUTE_VALUE_CONSTANT => $expectedSeparator,
623-
]);
627+
$this->setPropertyValue(
628+
$this->importProduct,
629+
'_parameters',
630+
[
631+
\Magento\ImportExport\Model\Import::FIELD_EMPTY_ATTRIBUTE_VALUE_CONSTANT => $expectedSeparator,
632+
]
633+
);
624634

625635
$this->assertEquals(
626636
$expectedSeparator,
@@ -632,9 +642,12 @@ public function testDeleteProductsForReplacement()
632642
{
633643
$importProduct = $this->getMockBuilder(Product::class)
634644
->disableOriginalConstructor()
635-
->setMethods([
636-
'setParameters', '_deleteProducts'
637-
])
645+
->setMethods(
646+
[
647+
'setParameters',
648+
'_deleteProducts'
649+
]
650+
)
638651
->getMock();
639652

640653
$importProduct->expects($this->once())->method('setParameters')->with(
@@ -764,9 +777,13 @@ public function testGetProductWebsites()
764777
'key 3' => 'val',
765778
];
766779
$expectedResult = array_keys($productValue);
767-
$this->setPropertyValue($this->importProduct, 'websitesCache', [
768-
$productSku => $productValue
769-
]);
780+
$this->setPropertyValue(
781+
$this->importProduct,
782+
'websitesCache',
783+
[
784+
$productSku => $productValue
785+
]
786+
);
770787

771788
$actualResult = $this->importProduct->getProductWebsites($productSku);
772789

@@ -785,9 +802,13 @@ public function testGetProductCategories()
785802
'key 3' => 'val',
786803
];
787804
$expectedResult = array_keys($productValue);
788-
$this->setPropertyValue($this->importProduct, 'categoriesCache', [
789-
$productSku => $productValue
790-
]);
805+
$this->setPropertyValue(
806+
$this->importProduct,
807+
'categoriesCache',
808+
[
809+
$productSku => $productValue
810+
]
811+
);
791812

792813
$actualResult = $this->importProduct->getProductCategories($productSku);
793814

@@ -1112,9 +1133,13 @@ public function testValidateRowSetAttributeSetCodeIntoRowData()
11121133
->disableOriginalConstructor()
11131134
->getMock();
11141135
$productType->expects($this->once())->method('isRowValid')->with($expectedRowData);
1115-
$this->setPropertyValue($importProduct, '_productTypeModels', [
1116-
$newSku['type_id'] => $productType
1117-
]);
1136+
$this->setPropertyValue(
1137+
$importProduct,
1138+
'_productTypeModels',
1139+
[
1140+
$newSku['type_id'] => $productType
1141+
]
1142+
);
11181143

11191144
//suppress option validation
11201145
$this->_rewriteGetOptionEntityInImportProduct($importProduct);
@@ -1229,6 +1254,56 @@ public function testParseAttributesWithWrappedValuesWillReturnsLowercasedAttribu
12291254
$this->assertArrayNotHasKey('PARAM2', $attributes);
12301255
}
12311256

1257+
/**
1258+
* @param bool $isRead
1259+
* @param bool $isWrite
1260+
* @param string $message
1261+
* @dataProvider fillUploaderObjectDataProvider
1262+
*/
1263+
public function testFillUploaderObject($isRead, $isWrite, $message)
1264+
{
1265+
$fileUploaderMock = $this
1266+
->getMockBuilder(\Magento\CatalogImportExport\Model\Import\Uploader::class)
1267+
->disableOriginalConstructor()
1268+
->getMock();
1269+
1270+
$fileUploaderMock
1271+
->method('setTmpDir')
1272+
->with('pub/media/import')
1273+
->willReturn($isRead);
1274+
1275+
$fileUploaderMock
1276+
->method('setDestDir')
1277+
->with('pub/media/catalog/product')
1278+
->willReturn($isWrite);
1279+
1280+
$this->_mediaDirectory
1281+
->method('getRelativePath')
1282+
->willReturnMap(
1283+
[
1284+
['import', 'import'],
1285+
['catalog/product', 'catalog/product'],
1286+
]
1287+
);
1288+
1289+
$this->_mediaDirectory
1290+
->method('create')
1291+
->with('pub/media/catalog/product');
1292+
1293+
$this->_uploaderFactory
1294+
->expects($this->once())
1295+
->method('create')
1296+
->willReturn($fileUploaderMock);
1297+
1298+
try {
1299+
$this->importProduct->getUploader();
1300+
$this->assertNotNull($this->getPropertyValue($this->importProduct, '_fileUploader'));
1301+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
1302+
$this->assertNull($this->getPropertyValue($this->importProduct, '_fileUploader'));
1303+
$this->assertEquals($message, $e->getMessage());
1304+
}
1305+
}
1306+
12321307
/**
12331308
* Test that errors occurred during importing images are logged.
12341309
*
@@ -1275,6 +1350,20 @@ function ($name) use ($throwException, $exception) {
12751350
);
12761351
}
12771352

1353+
/**
1354+
* Data provider for testFillUploaderObject.
1355+
*
1356+
* @return array
1357+
*/
1358+
public function fillUploaderObjectDataProvider()
1359+
{
1360+
return [
1361+
[false, true, 'File directory \'pub/media/import\' is not readable.'],
1362+
[true, false, 'File directory \'pub/media/catalog/product\' is not writable.'],
1363+
[true, true, ''],
1364+
];
1365+
}
1366+
12781367
/**
12791368
* Data provider for testUploadMediaFiles.
12801369
*

app/code/Magento/Indexer/Console/Command/IndexerStatusCommand.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
*/
66
namespace Magento\Indexer\Console\Command;
77

8-
use Symfony\Component\Console\Input\InputInterface;
9-
use Symfony\Component\Console\Output\OutputInterface;
108
use Magento\Framework\Indexer;
119
use Magento\Framework\Mview;
1210
use Symfony\Component\Console\Helper\Table;
11+
use Symfony\Component\Console\Input\InputInterface;
12+
use Symfony\Component\Console\Output\OutputInterface;
1313

1414
/**
1515
* Command for displaying status of indexers.
1616
*/
1717
class IndexerStatusCommand extends AbstractIndexerManageCommand
1818
{
1919
/**
20-
* {@inheritdoc}
20+
* @inheritdoc
2121
*/
2222
protected function configure()
2323
{
@@ -29,12 +29,14 @@ protected function configure()
2929
}
3030

3131
/**
32-
* {@inheritdoc}
32+
* @inheritdoc
33+
* @param InputInterface $input
34+
* @param OutputInterface $output
3335
*/
3436
protected function execute(InputInterface $input, OutputInterface $output)
3537
{
3638
$table = new Table($output);
37-
$table->setHeaders(['Title', 'Status', 'Update On', 'Schedule Status', 'Schedule Updated']);
39+
$table->setHeaders(['ID', 'Title', 'Status', 'Update On', 'Schedule Status', 'Schedule Updated']);
3840

3941
$rows = [];
4042

@@ -43,6 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4345
$view = $indexer->getView();
4446

4547
$rowData = [
48+
'ID' => $indexer->getId(),
4649
'Title' => $indexer->getTitle(),
4750
'Status' => $this->getStatus($indexer),
4851
'Update On' => $indexer->isScheduled() ? 'Schedule' : 'Save',
@@ -59,15 +62,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
5962
$rows[] = $rowData;
6063
}
6164

62-
usort($rows, function ($comp1, $comp2) {
63-
return strcmp($comp1['Title'], $comp2['Title']);
64-
});
65+
usort(
66+
$rows,
67+
function (array $comp1, array $comp2) {
68+
return strcmp($comp1['Title'], $comp2['Title']);
69+
}
70+
);
6571

6672
$table->addRows($rows);
6773
$table->render();
6874
}
6975

7076
/**
77+
* Returns the current status of the indexer
78+
*
7179
* @param Indexer\IndexerInterface $indexer
7280
* @return string
7381
*/
@@ -89,6 +97,8 @@ private function getStatus(Indexer\IndexerInterface $indexer)
8997
}
9098

9199
/**
100+
* Returns the pending count of the view
101+
*
92102
* @param Mview\ViewInterface $view
93103
* @return string
94104
*/

app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,47 +96,53 @@ public function testExecuteAll(array $indexers)
9696

9797
$linesOutput = array_filter(explode(PHP_EOL, $commandTester->getDisplay()));
9898

99-
$spacer = '+----------------+------------------+-----------+-------------------------+---------------------+';
99+
$spacer = '+-----------+----------------+------------------+-----------+-------------------------+'
100+
. '---------------------+';
100101

101102
$this->assertCount(8, $linesOutput, 'There should be 8 lines output. 3 Spacers, 1 header, 4 content.');
102103
$this->assertEquals($linesOutput[0], $spacer, "Lines 0, 2, 7 should be spacer lines");
103104
$this->assertEquals($linesOutput[2], $spacer, "Lines 0, 2, 7 should be spacer lines");
104105
$this->assertEquals($linesOutput[7], $spacer, "Lines 0, 2, 7 should be spacer lines");
105106

106107
$headerValues = array_values(array_filter(explode('|', $linesOutput[1])));
107-
$this->assertEquals('Title', trim($headerValues[0]));
108-
$this->assertEquals('Status', trim($headerValues[1]));
109-
$this->assertEquals('Update On', trim($headerValues[2]));
110-
$this->assertEquals('Schedule Status', trim($headerValues[3]));
111-
$this->assertEquals('Schedule Updated', trim($headerValues[4]));
108+
$this->assertEquals('ID', trim($headerValues[0]));
109+
$this->assertEquals('Title', trim($headerValues[1]));
110+
$this->assertEquals('Status', trim($headerValues[2]));
111+
$this->assertEquals('Update On', trim($headerValues[3]));
112+
$this->assertEquals('Schedule Status', trim($headerValues[4]));
113+
$this->assertEquals('Schedule Updated', trim($headerValues[5]));
112114

113115
$indexer1 = array_values(array_filter(explode('|', $linesOutput[3])));
114-
$this->assertEquals('Title_indexer1', trim($indexer1[0]));
115-
$this->assertEquals('Ready', trim($indexer1[1]));
116-
$this->assertEquals('Schedule', trim($indexer1[2]));
117-
$this->assertEquals('idle (10 in backlog)', trim($indexer1[3]));
118-
$this->assertEquals('2017-01-01 11:11:11', trim($indexer1[4]));
116+
$this->assertEquals('indexer_1', trim($indexer1[0]));
117+
$this->assertEquals('Title_indexer1', trim($indexer1[1]));
118+
$this->assertEquals('Ready', trim($indexer1[2]));
119+
$this->assertEquals('Schedule', trim($indexer1[3]));
120+
$this->assertEquals('idle (10 in backlog)', trim($indexer1[4]));
121+
$this->assertEquals('2017-01-01 11:11:11', trim($indexer1[5]));
119122

120123
$indexer2 = array_values(array_filter(explode('|', $linesOutput[4])));
121-
$this->assertEquals('Title_indexer2', trim($indexer2[0]));
122-
$this->assertEquals('Reindex required', trim($indexer2[1]));
123-
$this->assertEquals('Save', trim($indexer2[2]));
124-
$this->assertEquals('', trim($indexer2[3]));
124+
$this->assertEquals('indexer_2', trim($indexer2[0]));
125+
$this->assertEquals('Title_indexer2', trim($indexer2[1]));
126+
$this->assertEquals('Reindex required', trim($indexer2[2]));
127+
$this->assertEquals('Save', trim($indexer2[3]));
125128
$this->assertEquals('', trim($indexer2[4]));
129+
$this->assertEquals('', trim($indexer2[5]));
126130

127131
$indexer3 = array_values(array_filter(explode('|', $linesOutput[5])));
128-
$this->assertEquals('Title_indexer3', trim($indexer3[0]));
129-
$this->assertEquals('Processing', trim($indexer3[1]));
130-
$this->assertEquals('Schedule', trim($indexer3[2]));
131-
$this->assertEquals('idle (100 in backlog)', trim($indexer3[3]));
132-
$this->assertEquals('2017-01-01 11:11:11', trim($indexer3[4]));
132+
$this->assertEquals('indexer_3', trim($indexer3[0]));
133+
$this->assertEquals('Title_indexer3', trim($indexer3[1]));
134+
$this->assertEquals('Processing', trim($indexer3[2]));
135+
$this->assertEquals('Schedule', trim($indexer3[3]));
136+
$this->assertEquals('idle (100 in backlog)', trim($indexer3[4]));
137+
$this->assertEquals('2017-01-01 11:11:11', trim($indexer3[5]));
133138

134139
$indexer4 = array_values(array_filter(explode('|', $linesOutput[6])));
135-
$this->assertEquals('Title_indexer4', trim($indexer4[0]));
136-
$this->assertEquals('unknown', trim($indexer4[1]));
137-
$this->assertEquals('Schedule', trim($indexer4[2]));
138-
$this->assertEquals('running (20 in backlog)', trim($indexer4[3]));
139-
$this->assertEquals('2017-01-01 11:11:11', trim($indexer4[4]));
140+
$this->assertEquals('indexer_4', trim($indexer4[0]));
141+
$this->assertEquals('Title_indexer4', trim($indexer4[1]));
142+
$this->assertEquals('unknown', trim($indexer4[2]));
143+
$this->assertEquals('Schedule', trim($indexer4[3]));
144+
$this->assertEquals('running (20 in backlog)', trim($indexer4[4]));
145+
$this->assertEquals('2017-01-01 11:11:11', trim($indexer4[5]));
140146
}
141147

142148
/**

0 commit comments

Comments
 (0)