Skip to content

Commit 5e38d62

Browse files
Merge branch 'MC-11940' into 2.3-develop-mftf-pr15
2 parents e65d0a5 + 0dc1f67 commit 5e38d62

File tree

57 files changed

+802
-135
lines changed

Some content is hidden

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

57 files changed

+802
-135
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4335,7 +4335,7 @@ Tests:
43354335
* Fixed order placing with virtual product using Express Checkout
43364336
* Fixed the error during order placement with Recurring profile payment
43374337
* Fixed wrong redirect after customer registration during multishipping checkout
4338-
* Fixed inability to crate shipping labels
4338+
* Fixed inability to create shipping labels
43394339
* Fixed inability to switch language, if the default language is English
43404340
* Fixed an issue with incorrect XML appearing in cache after some actions on the frontend
43414341
* Fixed product export

app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ public function execute()
5858
$this->_coreRegistry->register('backup_manager', $backupManager);
5959

6060
if ($this->getRequest()->getParam('maintenance_mode')) {
61-
if (!$this->maintenanceMode->set(true)) {
61+
$this->maintenanceMode->set(true);
62+
63+
if (!$this->maintenanceMode->isOn()) {
6264
$response->setError(
6365
__(
6466
'You need more permissions to activate maintenance mode right now.'

app/code/Magento/Backup/Controller/Adminhtml/Index/Rollback.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
*/
77
namespace Magento\Backup\Controller\Adminhtml\Index;
88

9+
use Magento\Framework\App\Action\HttpPostActionInterface;
910
use Magento\Framework\App\Filesystem\DirectoryList;
1011
use Magento\Framework\Filesystem;
1112

1213
/**
14+
* Backup rollback controller.
15+
*
1316
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1417
*/
15-
class Rollback extends \Magento\Backup\Controller\Adminhtml\Index
18+
class Rollback extends \Magento\Backup\Controller\Adminhtml\Index implements HttpPostActionInterface
1619
{
1720
/**
1821
* Rollback Action
@@ -82,7 +85,9 @@ public function execute()
8285
}
8386

8487
if ($this->getRequest()->getParam('maintenance_mode')) {
85-
if (!$this->maintenanceMode->set(true)) {
88+
$this->maintenanceMode->set(true);
89+
90+
if (!$this->maintenanceMode->isOn()) {
8691
$response->setError(
8792
__(
8893
'You need more permissions to activate maintenance mode right now.'
@@ -122,6 +127,7 @@ public function execute()
122127
$adminSession->destroy();
123128

124129
$response->setRedirectUrl($this->getUrl('*'));
130+
// phpcs:disable Magento2.Exceptions.ThrowCatch
125131
} catch (\Magento\Framework\Backup\Exception\CantLoadSnapshot $e) {
126132
$errorMsg = __('We can\'t find the backup file.');
127133
} catch (\Magento\Framework\Backup\Exception\FtpConnectionFailed $e) {

app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function execute($product, $arguments = [])
206206
}
207207

208208
/**
209-
* Returns media gallery atribute instance
209+
* Returns media gallery attribute instance
210210
*
211211
* @return \Magento\Catalog\Api\Data\ProductAttributeInterface
212212
* @since 101.0.0
@@ -230,6 +230,7 @@ public function getAttribute()
230230
* @return void
231231
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
232232
* @since 101.0.0
233+
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
233234
*/
234235
protected function processDeletedImages($product, array &$images)
235236
{
@@ -400,6 +401,7 @@ protected function getUniqueFileName($file, $forTmp = false)
400401
$destinationFile = $forTmp
401402
? $this->mediaDirectory->getAbsolutePath($this->mediaConfig->getTmpMediaPath($file))
402403
: $this->mediaDirectory->getAbsolutePath($this->mediaConfig->getMediaPath($file));
404+
// phpcs:disable Magento2.Functions.DiscouragedFunction
403405
$destFile = dirname($file) . '/' . FileUploader::getNewFileName($destinationFile);
404406
}
405407

@@ -420,6 +422,7 @@ protected function copyImage($file)
420422
$destinationFile = $this->getUniqueFileName($file);
421423

422424
if (!$this->mediaDirectory->isFile($this->mediaConfig->getMediaPath($file))) {
425+
// phpcs:ignore Magento2.Exceptions.DirectThrow
423426
throw new \Exception();
424427
}
425428

@@ -437,6 +440,7 @@ protected function copyImage($file)
437440
}
438441

439442
return str_replace('\\', '/', $destinationFile);
443+
// phpcs:ignore Magento2.Exceptions.ThrowCatch
440444
} catch (\Exception $e) {
441445
$file = $this->mediaConfig->getMediaPath($file);
442446
throw new \Magento\Framework\Exception\LocalizedException(

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ protected function _prepareRowForDb(array $rowData)
12471247
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
12481248
* @SuppressWarnings(PHPMD.NPathComplexity)
12491249
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
1250+
* phpcs:disable Generic.Metrics.NestingLevel
12501251
*/
12511252
protected function _saveLinks()
12521253
{
@@ -1256,7 +1257,7 @@ protected function _saveLinks()
12561257
$nextLinkId = $this->_resourceHelper->getNextAutoincrement($mainTable);
12571258

12581259
// pre-load 'position' attributes ID for each link type once
1259-
foreach ($this->_linkNameToId as $linkName => $linkId) {
1260+
foreach ($this->_linkNameToId as $linkId) {
12601261
$select = $this->_connection->select()->from(
12611262
$resource->getTable('catalog_product_link_attribute'),
12621263
['id' => 'product_link_attribute_id']
@@ -1374,6 +1375,7 @@ protected function _saveLinks()
13741375
}
13751376
return $this;
13761377
}
1378+
// phpcs:enable
13771379

13781380
/**
13791381
* Save product attributes.
@@ -1608,6 +1610,7 @@ public function getImagesFromRow(array $rowData)
16081610
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
16091611
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
16101612
* @throws LocalizedException
1613+
* phpcs:disable Generic.Metrics.NestingLevel
16111614
*/
16121615
protected function _saveProducts()
16131616
{
@@ -1798,7 +1801,13 @@ protected function _saveProducts()
17981801
$uploadedImages[$columnImage] = $uploadedFile;
17991802
} else {
18001803
unset($rowData[$column]);
1801-
$this->skipRow($rowNum, ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE);
1804+
$this->addRowError(
1805+
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE,
1806+
$rowNum,
1807+
null,
1808+
null,
1809+
ProcessingError::ERROR_LEVEL_NOT_CRITICAL
1810+
);
18021811
}
18031812
} else {
18041813
$uploadedFile = $uploadedImages[$columnImage];
@@ -1974,6 +1983,7 @@ protected function _saveProducts()
19741983

19751984
return $this;
19761985
}
1986+
// phpcs:enable
19771987

19781988
/**
19791989
* Prepare array with image states (visible or hidden from product page)

app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Filter/Preprocessor.php

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use Magento\Catalog\Api\Data\ProductInterface;
99
use Magento\Catalog\Model\Product;
1010
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
11+
use Magento\CatalogSearch\Model\Search\FilterMapper\VisibilityFilter;
1112
use Magento\CatalogSearch\Model\Search\TableMapper;
13+
use Magento\Customer\Model\Session;
1214
use Magento\Eav\Model\Config;
1315
use Magento\Framework\App\Config\ScopeConfigInterface;
1416
use Magento\Framework\App\ObjectManager;
@@ -20,10 +22,11 @@
2022
use Magento\Framework\Search\Adapter\Mysql\Filter\PreprocessorInterface;
2123
use Magento\Framework\Search\Request\FilterInterface;
2224
use Magento\Store\Model\Store;
23-
use Magento\Customer\Model\Session;
24-
use Magento\CatalogSearch\Model\Search\FilterMapper\VisibilityFilter;
2525

2626
/**
27+
* ElasticSearch search filter pre-processor.
28+
*
29+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2730
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2831
* @deprecated
2932
* @see \Magento\ElasticSearch
@@ -128,18 +131,21 @@ public function __construct(
128131
}
129132

130133
/**
131-
* {@inheritdoc}
134+
* @inheritdoc
132135
*/
133136
public function process(FilterInterface $filter, $isNegation, $query)
134137
{
135138
return $this->processQueryWithField($filter, $isNegation, $query);
136139
}
137140

138141
/**
142+
* Process query with field.
143+
*
139144
* @param FilterInterface $filter
140145
* @param bool $isNegation
141146
* @param string $query
142147
* @return string
148+
* @throws \Magento\Framework\Exception\LocalizedException
143149
*/
144150
private function processQueryWithField(FilterInterface $filter, $isNegation, $query)
145151
{
@@ -170,7 +176,7 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
170176
} elseif ($filter->getField() === VisibilityFilter::VISIBILITY_FILTER_FIELD) {
171177
return '';
172178
} elseif ($filter->getType() === FilterInterface::TYPE_TERM &&
173-
in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true)
179+
in_array($attribute->getFrontendInput(), ['select', 'multiselect', 'boolean'], true)
174180
) {
175181
$resultQuery = $this->processTermSelect($filter, $isNegation);
176182
} elseif ($filter->getType() === FilterInterface::TYPE_RANGE &&
@@ -204,19 +210,23 @@ private function processQueryWithField(FilterInterface $filter, $isNegation, $qu
204210
->where('main_table.store_id = ?', Store::DEFAULT_STORE_ID)
205211
->having($query);
206212

207-
$resultQuery = 'search_index.entity_id IN (
208-
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
209-
)';
213+
$resultQuery = 'search_index.entity_id IN ('
214+
. 'select entity_id from '
215+
. $this->conditionManager->wrapBrackets($select)
216+
. ' as filter)';
210217
}
211218

212219
return $resultQuery;
213220
}
214221

215222
/**
223+
* Process range numeric.
224+
*
216225
* @param FilterInterface $filter
217226
* @param string $query
218227
* @param Attribute $attribute
219228
* @return string
229+
* @throws \Exception
220230
*/
221231
private function processRangeNumeric(FilterInterface $filter, $query, $attribute)
222232
{
@@ -238,14 +248,17 @@ private function processRangeNumeric(FilterInterface $filter, $query, $attribute
238248
->where('main_table.store_id = ?', $currentStoreId)
239249
->having($query);
240250

241-
$resultQuery = 'search_index.entity_id IN (
242-
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
243-
)';
251+
$resultQuery = 'search_index.entity_id IN ('
252+
. 'select entity_id from '
253+
. $this->conditionManager->wrapBrackets($select)
254+
. ' as filter)';
244255

245256
return $resultQuery;
246257
}
247258

248259
/**
260+
* Process term select.
261+
*
249262
* @param FilterInterface $filter
250263
* @param bool $isNegation
251264
* @return string

app/code/Magento/CatalogSearch/Model/Search/CustomAttributeFilterCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function isCustom(FilterInterface $filter)
4444

4545
return $attribute
4646
&& $filter->getType() === FilterInterface::TYPE_TERM
47-
&& in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true);
47+
&& in_array($attribute->getFrontendInput(), ['select', 'multiselect', 'boolean'], true);
4848
}
4949

5050
/**

app/code/Magento/Downloadable/Model/SampleRepository.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/**
2525
* Class SampleRepository
26+
*
2627
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2728
*/
2829
class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInterface
@@ -100,7 +101,7 @@ public function __construct(
100101
}
101102

102103
/**
103-
* {@inheritdoc}
104+
* @inheritdoc
104105
*/
105106
public function getList($sku)
106107
{
@@ -209,6 +210,8 @@ public function save(
209210
}
210211

211212
/**
213+
* Save sample.
214+
*
212215
* @param \Magento\Catalog\Api\Data\ProductInterface $product
213216
* @param SampleInterface $sample
214217
* @param bool $isGlobalScopeContent
@@ -257,6 +260,8 @@ protected function saveSample(
257260
}
258261

259262
/**
263+
* Update sample.
264+
*
260265
* @param \Magento\Catalog\Api\Data\ProductInterface $product
261266
* @param SampleInterface $sample
262267
* @param bool $isGlobalScopeContent
@@ -308,15 +313,18 @@ protected function updateSample(
308313
$existingSample->setTitle($sample->getTitle());
309314
}
310315

311-
if ($sample->getSampleType() === 'file' && $sample->getSampleFileContent() === null) {
312-
$sample->setSampleFile($existingSample->getSampleFile());
316+
if ($sample->getSampleType() === 'file'
317+
&& $sample->getSampleFileContent() === null
318+
&& $sample->getSampleFile() !== null
319+
) {
320+
$existingSample->setSampleFile($sample->getSampleFile());
313321
}
314322
$this->saveSample($product, $sample, $isGlobalScopeContent);
315323
return $existingSample->getId();
316324
}
317325

318326
/**
319-
* {@inheritdoc}
327+
* @inheritdoc
320328
*/
321329
public function delete($id)
322330
{

0 commit comments

Comments
 (0)