Skip to content

Commit 0d0aa22

Browse files
committed
Merge branch '2.4-develop' of github.com:magento/magento2 into ASI-1523-switching-between-views-does-not-change-the-selected-folder
2 parents a516ee5 + 4930963 commit 0d0aa22

File tree

725 files changed

+23608
-4310
lines changed

Some content is hidden

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

725 files changed

+23608
-4310
lines changed

app/autoload.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,48 @@
55
* Copyright © Magento, Inc. All rights reserved.
66
* See COPYING.txt for license details.
77
*/
8+
declare(strict_types=1);
9+
810
use Magento\Framework\Autoload\AutoloaderRegistry;
911
use Magento\Framework\Autoload\ClassLoaderWrapper;
1012

1113
/**
1214
* Shortcut constant for the root directory
1315
*/
14-
define('BP', dirname(__DIR__));
16+
\define('BP', \dirname(__DIR__));
1517

16-
define('VENDOR_PATH', BP . '/app/etc/vendor_path.php');
18+
\define('VENDOR_PATH', BP . '/app/etc/vendor_path.php');
1719

18-
if (!file_exists(VENDOR_PATH)) {
20+
if (!\is_readable(VENDOR_PATH)) {
1921
throw new \Exception(
2022
'We can\'t read some files that are required to run the Magento application. '
2123
. 'This usually means file permissions are set incorrectly.'
2224
);
2325
}
2426

25-
$vendorDir = require VENDOR_PATH;
26-
$vendorAutoload = BP . "/{$vendorDir}/autoload.php";
27+
$vendorAutoload = (
28+
static function (): ?string {
29+
$vendorDir = require VENDOR_PATH;
30+
31+
$vendorAutoload = BP . "/{$vendorDir}/autoload.php";
32+
if (\is_readable($vendorAutoload)) {
33+
return $vendorAutoload;
34+
}
35+
36+
$vendorAutoload = "{$vendorDir}/autoload.php";
37+
if (\is_readable($vendorAutoload)) {
38+
return $vendorAutoload;
39+
}
40+
41+
return null;
42+
}
43+
)();
2744

28-
/* 'composer install' validation */
29-
if (file_exists($vendorAutoload)) {
30-
$composerAutoloader = include $vendorAutoload;
31-
} else if (file_exists("{$vendorDir}/autoload.php")) {
32-
$vendorAutoload = "{$vendorDir}/autoload.php";
33-
$composerAutoloader = include $vendorAutoload;
34-
} else {
45+
if ($vendorAutoload === null) {
3546
throw new \Exception(
3647
'Vendor autoload is not found. Please run \'composer install\' under application root directory.'
3748
);
3849
}
3950

51+
$composerAutoloader = include $vendorAutoload;
4052
AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($composerAutoloader));

app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<?= /* @noEscape */ $secureRenderer->renderTag(
1313
'script',
1414
[
15-
'src' => '"' . $block->escapeJs($block->getTrackingUrl()) .'"',
15+
'src' => $block->getTrackingUrl(),
1616
'async' => true,
1717
],
1818
'&nbsp;',

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Price.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected function _getCurrencyList()
162162
/**
163163
* Retrieve filter value
164164
*
165-
* @param null $index
165+
* @param string|null $index
166166
* @return array|null
167167
*/
168168
public function getValue($index = null)
@@ -194,11 +194,11 @@ public function getCondition()
194194
$rate = $this->_getRate($displayCurrency, $this->_getColumnCurrencyCode());
195195

196196
if (isset($value['from'])) {
197-
$value['from'] *= $rate;
197+
$value['from'] = (float) $value['from'] * $rate;
198198
}
199199

200200
if (isset($value['to'])) {
201-
$value['to'] *= $rate;
201+
$value['to'] = (float) $value['to'] * $rate;
202202
}
203203

204204
$this->prepareRates($displayCurrency);

app/code/Magento/Backend/Block/Widget/Grid/Export.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Magento\Framework\App\Filesystem\DirectoryList;
1010

1111
/**
12+
* Class Export for exporting grid data as CSV file or MS Excel 2003 XML Document file
13+
*
1214
* @api
1315
* @deprecated 100.2.0 in favour of UI component implementation
1416
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -69,6 +71,8 @@ public function __construct(
6971
}
7072

7173
/**
74+
* Internal constructor, that is called from real constructor
75+
*
7276
* @return void
7377
* @throws \Magento\Framework\Exception\LocalizedException
7478
*/
@@ -242,6 +246,7 @@ protected function _getExportTotals()
242246

243247
/**
244248
* Iterate collection and call callback method per item
249+
*
245250
* For callback method first argument always is item object
246251
*
247252
* @param string $callback
@@ -273,7 +278,12 @@ public function _exportIterateCollection($callback, array $args)
273278

274279
$collection = $this->_getRowCollection($originalCollection);
275280
foreach ($collection as $item) {
276-
call_user_func_array([$this, $callback], array_merge([$item], $args));
281+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
282+
call_user_func_array(
283+
[$this, $callback],
284+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
285+
array_merge([$item], $args)
286+
);
277287
}
278288
}
279289
}
@@ -307,7 +317,7 @@ protected function _exportCsvItem(
307317
*/
308318
public function getCsvFile()
309319
{
310-
$name = md5(microtime());
320+
$name = hash('sha256', microtime());
311321
$file = $this->_path . '/' . $name . '.csv';
312322

313323
$this->_directory->create($this->_path);
@@ -432,11 +442,11 @@ public function getRowRecord(\Magento\Framework\DataObject $data)
432442
*/
433443
public function getExcelFile($sheetName = '')
434444
{
435-
$collection = $this->_getRowCollection();
445+
$collection = $this->_getPreparedCollection();
436446

437447
$convert = new \Magento\Framework\Convert\Excel($collection->getIterator(), [$this, 'getRowRecord']);
438448

439-
$name = md5(microtime());
449+
$name = hash('sha256', microtime());
440450
$file = $this->_path . '/' . $name . '.xml';
441451

442452
$this->_directory->create($this->_path);
@@ -551,6 +561,8 @@ public function _getPreparedCollection()
551561
}
552562

553563
/**
564+
* Get export page size
565+
*
554566
* @return int
555567
*/
556568
public function getExportPageSize()

app/code/Magento/Backend/Block/Widget/Grid/Extended.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Magento\Framework\App\Filesystem\DirectoryList;
99

1010
/**
11+
* Extended Grid Widget
12+
*
1113
* @api
1214
* @deprecated 100.2.0 in favour of UI component implementation
1315
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
@@ -177,7 +179,10 @@ class Extended extends \Magento\Backend\Block\Widget\Grid implements \Magento\Ba
177179
protected $_path = 'export';
178180

179181
/**
182+
* Initialization
183+
*
180184
* @return void
185+
* @throws \Magento\Framework\Exception\FileSystemException
181186
*/
182187
protected function _construct()
183188
{
@@ -297,6 +302,7 @@ public function addColumn($columnId, $column)
297302
);
298303
$this->getColumnSet()->getChildBlock($columnId)->setGrid($this);
299304
} else {
305+
// phpcs:ignore Magento2.Exceptions.DirectThrow
300306
throw new \Exception(__('Please correct the column format and try again.'));
301307
}
302308

@@ -471,10 +477,6 @@ protected function _prepareMassactionColumn()
471477
protected function _prepareCollection()
472478
{
473479
if ($this->getCollection()) {
474-
if ($this->getCollection()->isLoaded()) {
475-
$this->getCollection()->clear();
476-
}
477-
478480
parent::_prepareCollection();
479481

480482
if (!$this->_isExport) {
@@ -663,6 +665,7 @@ public function setEmptyCellLabel($label)
663665
*/
664666
public function getRowUrl($item)
665667
{
668+
// phpstan:ignore "Call to an undefined static method"
666669
$res = parent::getRowUrl($item);
667670
return $res ? $res : '#';
668671
}
@@ -680,6 +683,7 @@ public function getMultipleRows($item)
680683

681684
/**
682685
* Retrieve columns for multiple rows
686+
*
683687
* @return array
684688
*/
685689
public function getMultipleRowColumns()
@@ -943,6 +947,7 @@ protected function _getExportTotals()
943947

944948
/**
945949
* Iterate collection and call callback method per item
950+
*
946951
* For callback method first argument always is item object
947952
*
948953
* @param string $callback
@@ -972,7 +977,12 @@ public function _exportIterateCollection($callback, array $args)
972977
$page++;
973978

974979
foreach ($collection as $item) {
975-
call_user_func_array([$this, $callback], array_merge([$item], $args));
980+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
981+
call_user_func_array(
982+
[$this, $callback],
983+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
984+
array_merge([$item], $args)
985+
);
976986
}
977987
}
978988
}
@@ -1009,6 +1019,7 @@ public function getCsvFile()
10091019
$this->_isExport = true;
10101020
$this->_prepareGrid();
10111021

1022+
// phpcs:ignore Magento2.Security.InsecureFunction
10121023
$name = md5(microtime());
10131024
$file = $this->_path . '/' . $name . '.csv';
10141025

@@ -1153,6 +1164,7 @@ public function getExcelFile($sheetName = '')
11531164
[$this, 'getRowRecord']
11541165
);
11551166

1167+
// phpcs:ignore Magento2.Security.InsecureFunction
11561168
$name = md5(microtime());
11571169
$file = $this->_path . '/' . $name . '.xml';
11581170

@@ -1244,7 +1256,7 @@ public function setCollection($collection)
12441256
}
12451257

12461258
/**
1247-
* get collection object
1259+
* Get collection object
12481260
*
12491261
* @return \Magento\Framework\Data\Collection
12501262
*/

app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsTest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@
6464
<waitForLoadingMaskToDisappear stepKey="waitForLoadingCheckoutPageWithShippingMethod"/>
6565
<click selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
6666
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask1"/>
67-
<waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForNextButton"/>
68-
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNext"/>
67+
<actionGroup ref="StorefrontCheckoutClickNextButtonActionGroup" stepKey="clickNext"/>
6968
<!-- Checkout select Check/Money Order payment -->
7069
<comment userInput="Select Check/Money payment" stepKey="checkoutSelectCheckMoneyPayment"/>
7170
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment"/>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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\Backend\Test\Unit\Block\Widget\Grid\Column\Filter;
9+
10+
use Magento\Backend\Block\Context;
11+
use Magento\Backend\Block\Widget\Grid\Column;
12+
use Magento\Backend\Block\Widget\Grid\Column\Filter\Price;
13+
use Magento\Framework\App\RequestInterface;
14+
use Magento\Framework\DB\Helper;
15+
use Magento\Directory\Model\Currency;
16+
use Magento\Directory\Model\Currency\DefaultLocator;
17+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
18+
use PHPUnit\Framework\MockObject\MockObject;
19+
use PHPUnit\Framework\TestCase;
20+
21+
class PriceTest extends TestCase
22+
{
23+
/** @var RequestInterface|MockObject */
24+
private $requestMock;
25+
26+
/** @var Context|MockObject */
27+
private $context;
28+
29+
/** @var Helper|MockObject */
30+
private $helper;
31+
32+
/** @var Currency|MockObject */
33+
private $currency;
34+
35+
/** @var DefaultLocator|MockObject */
36+
private $currencyLocator;
37+
38+
/** @var Column|MockObject */
39+
private $columnMock;
40+
41+
/** @var Price */
42+
private $blockPrice;
43+
44+
protected function setUp(): void
45+
{
46+
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
47+
48+
$this->context = $this->createMock(Context::class);
49+
$this->context->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
50+
51+
$this->helper = $this->createMock(Helper::class);
52+
53+
$this->currency = $this->getMockBuilder(Currency::class)
54+
->disableOriginalConstructor()
55+
->setMethods(['getAnyRate'])
56+
->getMock();
57+
58+
$this->currencyLocator = $this->createMock(DefaultLocator::class);
59+
60+
$this->columnMock = $this->getMockBuilder(Column::class)
61+
->disableOriginalConstructor()
62+
->setMethods(['getCurrencyCode'])
63+
->getMock();
64+
65+
$helper = new ObjectManager($this);
66+
67+
$this->blockPrice = $helper->getObject(Price::class, [
68+
'context' => $this->context,
69+
'resourceHelper' => $this->helper,
70+
'currencyModel' => $this->currency,
71+
'currencyLocator' => $this->currencyLocator
72+
]);
73+
$this->blockPrice->setColumn($this->columnMock);
74+
}
75+
76+
public function testGetCondition()
77+
{
78+
$this->currencyLocator->expects(
79+
$this->any()
80+
)->method(
81+
'getDefaultCurrency'
82+
)->with(
83+
$this->requestMock
84+
)->willReturn(
85+
'defaultCurrency'
86+
);
87+
88+
$this->currency->expects($this->at(0))
89+
->method('getAnyRate')
90+
->with('defaultCurrency')
91+
->willReturn(1.0);
92+
93+
$testValue = [
94+
'value' => [
95+
'from' => '1234a',
96+
]
97+
];
98+
99+
$this->blockPrice->addData($testValue);
100+
$this->assertEquals(['from' => 1234], $this->blockPrice->getCondition());
101+
}
102+
}

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/ExtendedTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public function testPrepareLoadedCollection()
4141
$layout->expects($this->any())->method('getBlock')->willReturn($columnSet);
4242

4343
$collection = $this->createMock(Collection::class);
44-
$collection->expects($this->atLeastOnce())->method('isLoaded')->willReturn(true);
45-
$collection->expects($this->atLeastOnce())->method('clear');
44+
$collection->expects($this->never())->method('isLoaded');
45+
$collection->expects($this->never())->method('clear');
4646
$collection->expects($this->atLeastOnce())->method('load');
4747

4848
/** @var Extended $block */

app/code/Magento/Backend/view/adminhtml/layout/default.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
<argument name="bugreport_url" xsi:type="string">https://github.com/magento/magento2/issues</argument>
7171
</arguments>
7272
</block>
73-
7473
</container>
7574
</container>
7675
</referenceContainer>

0 commit comments

Comments
 (0)