Skip to content

Commit fcdc7f7

Browse files
committed
Merge branch 'ACQE-5379' of https://github.com/magento-pangolin/magento2ce into ACQE-5379
2 parents 1a4b101 + 014502f commit fcdc7f7

File tree

318 files changed

+13996
-30945
lines changed

Some content is hidden

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

318 files changed

+13996
-30945
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,16 +893,24 @@ public function fileClose($resource): bool
893893
*/
894894
public function fileOpen($path, $mode)
895895
{
896+
$_mode = str_replace(['b', '+'], '', strtolower($mode));
897+
if (!in_array($_mode, ['r', 'w', 'a'], true)) {
898+
throw new FileSystemException(new Phrase('Invalid file open mode "%1".', [$mode]));
899+
}
896900
$path = $this->normalizeRelativePath($path, true);
897901

898902
if (!isset($this->streams[$path])) {
899903
$this->streams[$path] = tmpfile();
900904
try {
901905
if ($this->adapter->fileExists($path)) {
902-
//phpcs:ignore Magento2.Functions.DiscouragedFunction
903-
fwrite($this->streams[$path], $this->adapter->read($path));
904-
//phpcs:ignore Magento2.Functions.DiscouragedFunction
905-
rewind($this->streams[$path]);
906+
if ($_mode !== 'w') {
907+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
908+
fwrite($this->streams[$path], $this->adapter->read($path));
909+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
910+
if ($_mode !== 'a') {
911+
rewind($this->streams[$path]);
912+
}
913+
}
906914
}
907915
} catch (FlysystemFilesystemException $e) {
908916
$this->logger->error($e->getMessage());

app/code/Magento/AwsS3/Test/Unit/Driver/AwsS3Test.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,42 @@ public function testFileCloseShouldReturnFalseIfTheArgumentIsNotAResource(): voi
537537
$this->assertEquals(false, $this->driver->fileClose(null));
538538
$this->assertEquals(false, $this->driver->fileClose(false));
539539
}
540+
541+
/**
542+
* @dataProvider fileOpenModesDataProvider
543+
*/
544+
public function testFileOppenedMode($mode, $expected): void
545+
{
546+
$this->adapterMock->method('fileExists')->willReturn(true);
547+
if ($mode !== 'w') {
548+
$this->adapterMock->expects($this->once())->method('read')->willReturn('aaa');
549+
} else {
550+
$this->adapterMock->expects($this->never())->method('read');
551+
}
552+
$resource = $this->driver->fileOpen('test/path', $mode);
553+
$this->assertEquals($expected, ftell($resource));
554+
}
555+
556+
/**
557+
* Data provider for testFileOppenedMode
558+
*
559+
* @return array[]
560+
*/
561+
public function fileOpenModesDataProvider(): array
562+
{
563+
return [
564+
[
565+
"mode" => "a",
566+
"expected" => 3
567+
],
568+
[
569+
"mode" => "r",
570+
"expected" => 0
571+
],
572+
[
573+
"mode" => "w",
574+
"expected" => 0
575+
]
576+
];
577+
}
540578
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,7 @@ public function getCsvFile()
10221022
$stream = $this->_directory->openFile($file, 'w+');
10231023

10241024
$stream->lock();
1025+
$stream->write(pack('CCC', 0xef, 0xbb, 0xbf));
10251026
$stream->writeCsv($this->_getExportHeaders());
10261027
$this->_exportIterateCollection('_exportCsvItem', [$stream]);
10271028

app/code/Magento/Backup/Model/Fs/Collection.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class Collection extends \Magento\Framework\Data\Collection\Filesystem
2929
protected $_path = 'backups';
3030

3131
/**
32-
* Backup data
33-
*
3432
* @var \Magento\Backup\Helper\Data
3533
*/
3634
protected $_backupData = null;
@@ -46,7 +44,9 @@ class Collection extends \Magento\Framework\Data\Collection\Filesystem
4644
* @var \Magento\Framework\Filesystem
4745
*/
4846
private $_filesystem;
47+
4948
/**
49+
*
5050
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
5151
* @param \Magento\Backup\Helper\Data $backupData
5252
* @param \Magento\Framework\Filesystem $filesystem
@@ -61,21 +61,26 @@ public function __construct(
6161
) {
6262
$this->_backupData = $backupData;
6363
parent::__construct($entityFactory, $filesystem);
64-
6564
$this->_filesystem = $filesystem;
6665
$this->_backup = $backup;
6766
$this->_varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
68-
6967
$this->_hideBackupsForApache();
68+
$this->initialize();
69+
}
7070

71+
/**
72+
* Initialize collection
73+
*
74+
* @return void
75+
*/
76+
private function initialize()
77+
{
7178
// set collection specific params
7279
$extensions = $this->_backupData->getExtensions();
73-
7480
foreach ($extensions as $value) {
7581
$extensions[] = '(' . preg_quote($value, '/') . ')';
7682
}
7783
$extensions = implode('|', $extensions);
78-
7984
$this->_varDirectory->create($this->_path);
8085
$path = rtrim($this->_varDirectory->getAbsolutePath($this->_path), '/') . '/';
8186
$this->setOrder(
@@ -90,6 +95,15 @@ public function __construct(
9095
);
9196
}
9297

98+
/**
99+
* @inheritDoc
100+
*/
101+
public function _resetState(): void
102+
{
103+
parent::_resetState();
104+
$this->initialize();
105+
}
106+
93107
/**
94108
* Create .htaccess file and deny backups directory access from web
95109
*

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
namespace Magento\Bundle\Model\ResourceModel\Indexer;
77

88
use Magento\Catalog\Api\Data\ProductInterface;
9-
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BasePriceModifier;
10-
use Magento\Framework\DB\Select;
11-
use Magento\Framework\Indexer\DimensionalIndexerInterface;
12-
use Magento\Framework\EntityManager\MetadataPool;
139
use Magento\Catalog\Model\Indexer\Product\Price\TableMaintainer;
14-
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructureFactory;
10+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
11+
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BasePriceModifier;
1512
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructure;
13+
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructureFactory;
1614
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\Query\JoinAttributeProcessor;
15+
use Magento\CatalogInventory\Model\Stock;
1716
use Magento\Customer\Model\Indexer\CustomerGroupDimensionProvider;
17+
use Magento\Framework\DB\Select;
18+
use Magento\Framework\EntityManager\MetadataPool;
19+
use Magento\Framework\Indexer\DimensionalIndexerInterface;
1820
use Magento\Store\Model\Indexer\WebsiteDimensionProvider;
19-
use Magento\Catalog\Model\Product\Attribute\Source\Status;
20-
use Magento\CatalogInventory\Model\Stock;
2121

2222
/**
2323
* Bundle products Price indexer resource model
@@ -671,10 +671,9 @@ private function calculateFixedBundleSelectionPrice()
671671
* @return void
672672
* @throws \Exception
673673
*/
674-
private function calculateDynamicBundleSelectionPrice($dimensions)
674+
private function calculateDynamicBundleSelectionPrice(array $dimensions): void
675675
{
676676
$connection = $this->getConnection();
677-
678677
$price = 'idx.min_price * bs.selection_qty';
679678
$specialExpr = $connection->getCheckSql(
680679
'i.special_price > 0 AND i.special_price < 100',
@@ -716,8 +715,32 @@ private function calculateDynamicBundleSelectionPrice($dimensions)
716715
[]
717716
);
718717
$select->where('si.stock_status = ?', Stock::STOCK_IN_STOCK);
718+
$query = str_replace('AS `idx`', 'AS `idx` USE INDEX (PRIMARY)', (string) $select);
719+
$insertColumns = [
720+
'entity_id',
721+
'customer_group_id',
722+
'website_id',
723+
'option_id',
724+
'selection_id',
725+
'group_type',
726+
'is_required',
727+
'price',
728+
'tier_price'
729+
];
730+
$insertColumns = array_map(function ($item) use ($connection) {
731+
return $connection->quoteIdentifier($item);
732+
}, $insertColumns);
733+
$updateValues = [];
734+
foreach ($insertColumns as $column) {
735+
$updateValues[] = sprintf("%s = VALUES(%s)", $column, $column);
736+
}
719737

720-
$this->tableMaintainer->insertFromSelect($select, $this->getBundleSelectionTable(), []);
738+
$connection->query(sprintf(
739+
"INSERT INTO `" . $this->getBundleSelectionTable() . "` (%s) %s ON DUPLICATE KEY UPDATE %s",
740+
implode(",", $insertColumns),
741+
$query,
742+
implode(",", $updateValues)
743+
));
721744
}
722745

723746
/**

app/code/Magento/Bundle/Pricing/Adjustment/DefaultSelectionPriceListProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,6 @@ private function getBundleOptions(Product $saleableItem)
255255
*/
256256
public function _resetState(): void
257257
{
258-
$this->priceList = [];
258+
$this->priceList = null;
259259
}
260260
}

0 commit comments

Comments
 (0)