Skip to content

Commit 847b028

Browse files
merge magento/2.3-develop into magento-tsg/2.3-develop-pr44
2 parents a4d19e9 + 18dc53f commit 847b028

File tree

95 files changed

+3850
-952
lines changed

Some content is hidden

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

95 files changed

+3850
-952
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/Config/Model/Config/Backend/Serialized.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Magento\Framework\Serialize\Serializer\Json;
1010

1111
/**
12+
* Serialized backend model
13+
*
1214
* @api
1315
* @since 100.0.2
1416
*/
@@ -46,17 +48,32 @@ public function __construct(
4648
}
4749

4850
/**
51+
* Processing object after load data
52+
*
4953
* @return void
5054
*/
5155
protected function _afterLoad()
5256
{
5357
$value = $this->getValue();
5458
if (!is_array($value)) {
55-
$this->setValue(empty($value) ? false : $this->serializer->unserialize($value));
59+
try {
60+
$this->setValue(empty($value) ? false : $this->serializer->unserialize($value));
61+
} catch (\Exception $e) {
62+
$this->_logger->critical(
63+
sprintf(
64+
'Failed to unserialize %s config value. The error is: %s',
65+
$this->getPath(),
66+
$e->getMessage()
67+
)
68+
);
69+
$this->setValue(false);
70+
}
5671
}
5772
}
5873

5974
/**
75+
* Processing object before save data
76+
*
6077
* @return $this
6178
*/
6279
public function beforeSave()

app/code/Magento/Config/Test/Unit/Model/Config/Backend/SerializedTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
use Magento\Framework\Model\Context;
1010
use Magento\Framework\Serialize\Serializer\Json;
1111
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12+
use Psr\Log\LoggerInterface;
1213

14+
/**
15+
* Class SerializedTest
16+
*/
1317
class SerializedTest extends \PHPUnit\Framework\TestCase
1418
{
1519
/** @var \Magento\Config\Model\Config\Backend\Serialized */
@@ -18,14 +22,20 @@ class SerializedTest extends \PHPUnit\Framework\TestCase
1822
/** @var Json|\PHPUnit_Framework_MockObject_MockObject */
1923
private $serializerMock;
2024

25+
/** @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */
26+
private $loggerMock;
27+
2128
protected function setUp()
2229
{
2330
$objectManager = new ObjectManager($this);
2431
$this->serializerMock = $this->createMock(Json::class);
32+
$this->loggerMock = $this->createMock(LoggerInterface::class);
2533
$contextMock = $this->createMock(Context::class);
2634
$eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
2735
$contextMock->method('getEventDispatcher')
2836
->willReturn($eventManagerMock);
37+
$contextMock->method('getLogger')
38+
->willReturn($this->loggerMock);
2939
$this->serializedConfig = $objectManager->getObject(
3040
Serialized::class,
3141
[
@@ -72,6 +82,20 @@ public function afterLoadDataProvider()
7282
];
7383
}
7484

85+
public function testAfterLoadWithException()
86+
{
87+
$value = '{"key":';
88+
$expected = false;
89+
$this->serializedConfig->setValue($value);
90+
$this->serializerMock->expects($this->once())
91+
->method('unserialize')
92+
->willThrowException(new \Exception());
93+
$this->loggerMock->expects($this->once())
94+
->method('critical');
95+
$this->serializedConfig->afterLoad();
96+
$this->assertEquals($expected, $this->serializedConfig->getValue());
97+
}
98+
7599
/**
76100
* @param string $expected
77101
* @param int|double|string|array|boolean|null $value

0 commit comments

Comments
 (0)