Skip to content

Commit a5dc1a7

Browse files
authored
Merge pull request #4227 from magento-tsg/2.3.2-develop-pr51
[TSG] Fixes for 2.3.2 (pr51) (2.3.2-develop)
2 parents ba04983 + 3e9172b commit a5dc1a7

File tree

16 files changed

+352
-29
lines changed

16 files changed

+352
-29
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ private function isDeployed(Package $package)
339339
if ($this->isCanBeParalleled()) {
340340
if ($package->getState() === null) {
341341
// phpcs:ignore Magento2.Functions.DiscouragedFunction
342-
$pid = pcntl_waitpid($this->getPid($package), $status, WNOHANG);
342+
$pid = pcntl_waitpid($this->getPid($package) ?? 0, $status, WNOHANG);
343343
if ($pid === $this->getPid($package)) {
344344
$package->setState(Package::STATE_COMPLETED);
345345

@@ -361,7 +361,7 @@ private function isDeployed(Package $package)
361361
*/
362362
private function getPid(Package $package)
363363
{
364-
return isset($this->processIds[$package->getPath()]) ?? null;
364+
return $this->processIds[$package->getPath()] ?? null;
365365
}
366366

367367
/**

app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function resolve(): SearchCriteria
7979
$this->builder->setPageSize($this->size);
8080
$searchCriteria = $this->builder->create();
8181
$searchCriteria->setRequestName($this->searchRequestName);
82-
$searchCriteria->setSortOrders(array_merge(['relevance' => 'DESC'], $this->orders));
82+
$searchCriteria->setSortOrders($this->orders);
8383
$searchCriteria->setCurrentPage($this->currentPage - 1);
8484

8585
return $searchCriteria;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Elasticsearch\Test\Unit\Model\ResourceModel\Fulltext\Collection;
9+
10+
use Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection\SearchCriteriaResolver;
11+
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
12+
use Magento\Framework\Api\Search\SearchCriteria;
13+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
14+
15+
/**
16+
* Unit test for SearchCriteriaResolver
17+
*/
18+
class SearchCriteriaResolverTest extends \PHPUnit\Framework\TestCase
19+
{
20+
/**
21+
* @var SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
private $searchCriteriaBuilder;
24+
25+
/**
26+
* @inheritdoc
27+
*/
28+
protected function setUp()
29+
{
30+
$this->searchCriteriaBuilder = $this->getMockBuilder(SearchCriteriaBuilder::class)
31+
->disableOriginalConstructor()
32+
->setMethods(['setPageSize', 'create'])
33+
->getMock();
34+
}
35+
36+
/**
37+
* @param array|null $orders
38+
* @param array|null $expected
39+
* @dataProvider resolveSortOrderDataProvider
40+
*/
41+
public function testResolve($orders, $expected)
42+
{
43+
$searchRequestName = 'test';
44+
$currentPage = 1;
45+
$size = 10;
46+
47+
$searchCriteria = $this->getMockBuilder(SearchCriteria::class)
48+
->disableOriginalConstructor()
49+
->setMethods(['setRequestName', 'setSortOrders', 'setCurrentPage'])
50+
->getMock();
51+
$searchCriteria->expects($this->once())
52+
->method('setRequestName')
53+
->with($searchRequestName)
54+
->willReturn($searchCriteria);
55+
$searchCriteria->expects($this->once())
56+
->method('setSortOrders')
57+
->with($expected)
58+
->willReturn($searchCriteria);
59+
$searchCriteria->expects($this->once())
60+
->method('setCurrentPage')
61+
->with($currentPage - 1)
62+
->willReturn($searchCriteria);
63+
64+
$this->searchCriteriaBuilder->expects($this->once())
65+
->method('create')
66+
->willReturn($searchCriteria);
67+
$this->searchCriteriaBuilder->expects($this->once())
68+
->method('setPageSize')
69+
->with($size)
70+
->willReturn($this->searchCriteriaBuilder);
71+
72+
$objectManager = new ObjectManagerHelper($this);
73+
/** @var SearchCriteriaResolver $model */
74+
$model = $objectManager->getObject(
75+
SearchCriteriaResolver::class,
76+
[
77+
'builder' => $this->searchCriteriaBuilder,
78+
'searchRequestName' => $searchRequestName,
79+
'currentPage' => $currentPage,
80+
'size' => $size,
81+
'orders' => $orders,
82+
]
83+
);
84+
85+
$model->resolve();
86+
}
87+
88+
/**
89+
* @return array
90+
*/
91+
public function resolveSortOrderDataProvider()
92+
{
93+
return [
94+
[
95+
null,
96+
null,
97+
],
98+
[
99+
['test' => 'ASC'],
100+
['test' => 'ASC'],
101+
],
102+
];
103+
}
104+
}

app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\ImportExport\Controller\Adminhtml\Export\File;
99

1010
use Magento\Backend\App\Action;
11-
use Magento\Framework\App\Action\HttpGetActionInterface;
11+
use Magento\Framework\App\Action\HttpPostActionInterface;
1212
use Magento\Framework\Controller\ResultFactory;
1313
use Magento\Framework\Exception\FileSystemException;
1414
use Magento\Framework\Exception\LocalizedException;
@@ -20,12 +20,12 @@
2020
/**
2121
* Controller that delete file by name.
2222
*/
23-
class Delete extends ExportController implements HttpGetActionInterface
23+
class Delete extends ExportController implements HttpPostActionInterface
2424
{
2525
/**
26-
* url to this controller
26+
* Url to this controller
2727
*/
28-
const URL = 'admin/export_file/delete';
28+
const URL = 'adminhtml/export_file/delete';
2929

3030
/**
3131
* @var Filesystem

app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
class Download extends ExportController implements HttpGetActionInterface
2222
{
2323
/**
24-
* url to this controller
24+
* Url to this controller
2525
*/
26-
const URL = 'admin/export_file/download/';
26+
const URL = 'adminhtml/export_file/download/';
2727

2828
/**
2929
* @var FileFactory

app/code/Magento/ImportExport/Ui/Component/Columns/ExportGridActions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public function prepareDataSource(array $dataSource)
6565
'confirm' => [
6666
'title' => __('Delete'),
6767
'message' => __('Are you sure you wan\'t to delete a file?')
68-
]
68+
],
69+
'post' => true,
6970
];
7071
}
7172
}

app/code/Magento/Sales/Controller/Guest/View.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Sales\Controller\Guest;
77

88
use Magento\Framework\App\Action;
9+
use Magento\Framework\App\Action\HttpGetActionInterface;
910
use Magento\Sales\Helper\Guest as GuestHelper;
1011
use Magento\Framework\View\Result\PageFactory;
1112
use Magento\Framework\Controller\ResultInterface;
@@ -14,7 +15,7 @@
1415
/**
1516
* Guest order view action.
1617
*/
17-
class View extends Action\Action implements HttpPostActionInterface
18+
class View extends Action\Action implements HttpPostActionInterface, HttpGetActionInterface
1819
{
1920
/**
2021
* @var \Magento\Sales\Helper\Guest

app/code/Magento/Sales/Helper/Admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public function escapeHtmlWithLinks($data, $allowedTags = null)
166166

167167
$internalErrors = libxml_use_internal_errors(true);
168168

169+
$data = mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8');
169170
$domDocument->loadHTML(
170171
'<html><body id="' . $wrapperElementId . '">' . $data . '</body></html>'
171172
);

app/code/Magento/SalesRule/Observer/CouponCodeValidation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public function execute(EventObserver $observer)
6464
//Only validating the code if it's a new code.
6565
/** @var Quote[] $found */
6666
$found = $this->cartRepository->getList(
67-
$this->criteriaBuilder->addFilter(CartInterface::KEY_ENTITY_ID, $quote->getId())->create()
67+
$this->criteriaBuilder->addFilter('main_table.' . CartInterface::KEY_ENTITY_ID, $quote->getId())
68+
->create()
6869
)->getItems();
6970
if (!$found || ((string)array_shift($found)->getCouponCode()) !== (string)$code) {
7071
try {

app/code/Magento/Swatches/view/adminhtml/web/css/swatches.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,6 @@
153153
min-width: 65px;
154154
}
155155

156-
[class^=swatch-col],
157-
[class^=col-]:not(.col-draggable):not(.col-default) {
158-
min-width: 150px;
159-
}
160-
161-
#swatch-visual-options-panel,
162-
#swatch-text-options-panel,
163-
#manage-options-panel {
164-
overflow: auto;
165-
width: 100%;
166-
}
167-
168156
.data-table .col-swatch-min-width input[type="text"] {
169157
padding: inherit;
170158
}

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class Actions extends Block
107107
*
108108
* @var string
109109
*/
110-
protected $orderInvoiceCreditMemo = '#capture';
110+
protected $orderInvoiceCreditMemo = '#credit-memo';
111111

112112
/**
113113
* 'Refund' button.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ImportExport\Controller\Adminhtml\Export\File;
9+
10+
use Magento\Framework\App\Filesystem\DirectoryList;
11+
use Magento\Framework\App\Request\Http;
12+
use Magento\Framework\Filesystem;
13+
use Magento\Framework\Filesystem\Directory\WriteInterface;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use Magento\TestFramework\TestCase\AbstractBackendController;
16+
17+
/**
18+
* Test for \Magento\ImportExport\Controller\Adminhtml\Export\File\Delete class.
19+
*/
20+
class DeleteTest extends AbstractBackendController
21+
{
22+
/**
23+
* @var WriteInterface
24+
*/
25+
private $varDirectory;
26+
27+
/**
28+
* @var string
29+
*/
30+
private $fileName = 'catalog_product.csv';
31+
32+
/**
33+
* @inheritdoc
34+
*/
35+
protected function setUp()
36+
{
37+
parent::setUp();
38+
39+
$filesystem = $this->_objectManager->get(Filesystem::class);
40+
$sourceFilePath = __DIR__ . '/../../Import/_files' . DIRECTORY_SEPARATOR . $this->fileName;
41+
$destinationFilePath = 'export' . DIRECTORY_SEPARATOR . $this->fileName;
42+
//Refers to tests 'var' directory
43+
$this->varDirectory = $filesystem->getDirectoryRead(DirectoryList::VAR_DIR);
44+
//Refers to application root directory
45+
$rootDirectory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
46+
$rootDirectory->copyFile($sourceFilePath, $this->varDirectory->getAbsolutePath($destinationFilePath));
47+
}
48+
49+
/**
50+
* Check that file can be removed under var/export directory.
51+
*
52+
* @return void
53+
* @magentoConfigFixture default_store admin/security/use_form_key 1
54+
*/
55+
public function testExecute(): void
56+
{
57+
$request = $this->getRequest();
58+
$request->setParam('filename', $this->fileName);
59+
$request->setMethod(Http::METHOD_POST);
60+
61+
if ($this->varDirectory->isExist('export/' . $this->fileName)) {
62+
$this->dispatch('backend/admin/export_file/delete');
63+
} else {
64+
throw new \AssertionError('Export product file supposed to exist');
65+
}
66+
67+
$this->assertFalse($this->varDirectory->isExist('export/' . $this->fileName));
68+
}
69+
70+
/**
71+
* @inheritdoc
72+
*/
73+
public static function tearDownAfterClass()
74+
{
75+
$filesystem = Bootstrap::getObjectManager()->get(Filesystem::class);
76+
/** @var WriteInterface $directory */
77+
$directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
78+
if ($directory->isExist('export')) {
79+
$directory->delete('export');
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)