Skip to content

Commit adc4105

Browse files
authored
Merge pull request #8346 from magento-gl/Sync-2.4.7-beta1-develop
[DO NOT MERGE UNTIL 2.4.7-beta1 GA] 2.4.7-beta1-develop-sync
2 parents 827073a + 2f62d75 commit adc4105

File tree

156 files changed

+2029
-887
lines changed

Some content is hidden

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

156 files changed

+2029
-887
lines changed

app/code/Magento/Backend/Model/Auth/Session.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ public function __construct(
114114
);
115115
}
116116

117+
/**
118+
* @inheritDoc
119+
*/
120+
public function _resetState(): void
121+
{
122+
parent::_resetState();
123+
$this->_isFirstAfterLogin = null;
124+
$this->acl = null;
125+
}
126+
117127
/**
118128
* Refresh ACL resources stored in session
119129
*

app/code/Magento/Backend/Model/Session/Quote.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ public function __construct(
139139
}
140140
}
141141

142+
/**
143+
* @inheritDoc
144+
*/
145+
public function _resetState(): void
146+
{
147+
parent::_resetState();
148+
$this->_quote = null;
149+
$this->_store = null;
150+
$this->_order = null;
151+
}
152+
142153
/**
143154
* Retrieve quote model object
144155
*
@@ -154,7 +165,7 @@ public function getQuote()
154165
$this->_quote->setCustomerGroupId($customerGroupId);
155166
$this->_quote->setIsActive(false);
156167
$this->_quote->setStoreId($this->getStoreId());
157-
168+
158169
$this->quoteRepository->save($this->_quote);
159170
$this->setQuoteId($this->_quote->getId());
160171
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);

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

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

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

11-
class Download extends \Magento\Backup\Controller\Adminhtml\Index
12+
class Download extends \Magento\Backup\Controller\Adminhtml\Index implements HttpGetActionInterface
1213
{
1314
/**
1415
* @var \Magento\Framework\Controller\Result\RawFactory
@@ -66,17 +67,12 @@ public function execute()
6667

6768
$fileName = $this->_objectManager->get(\Magento\Backup\Helper\Data::class)->generateBackupDownloadName($backup);
6869

69-
$this->_fileFactory->create(
70+
return $this->_fileFactory->create(
7071
$fileName,
71-
null,
72+
['type' => 'filename', 'value' => $backup->getPath() . DIRECTORY_SEPARATOR . $backup->getFileName()],
7273
DirectoryList::VAR_DIR,
7374
'application/octet-stream',
7475
$backup->getSize()
7576
);
76-
77-
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
78-
$resultRaw = $this->resultRawFactory->create();
79-
$resultRaw->setContents($backup->output());
80-
return $resultRaw;
8177
}
8278
}

app/code/Magento/Backup/Test/Unit/Controller/Adminhtml/Index/DownloadTest.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected function setUp(): void
115115
->getMock();
116116
$this->backupModelMock = $this->getMockBuilder(Backup::class)
117117
->disableOriginalConstructor()
118-
->setMethods(['getTime', 'exists', 'getSize', 'output'])
118+
->setMethods(['getTime', 'exists', 'getSize', 'output', 'getPath', 'getFileName'])
119119
->getMock();
120120
$this->dataHelperMock = $this->getMockBuilder(Data::class)
121121
->disableOriginalConstructor()
@@ -169,8 +169,13 @@ public function testExecuteBackupFound()
169169
$type = 'db';
170170
$filename = 'filename';
171171
$size = 10;
172-
$output = 'test';
173-
172+
$path = 'testpath';
173+
$this->backupModelMock->expects($this->atLeastOnce())
174+
->method('getPath')
175+
->willReturn($path);
176+
$this->backupModelMock->expects($this->atLeastOnce())
177+
->method('getFileName')
178+
->willReturn($filename);
174179
$this->backupModelMock->expects($this->atLeastOnce())
175180
->method('getTime')
176181
->willReturn($time);
@@ -180,9 +185,6 @@ public function testExecuteBackupFound()
180185
$this->backupModelMock->expects($this->atLeastOnce())
181186
->method('getSize')
182187
->willReturn($size);
183-
$this->backupModelMock->expects($this->atLeastOnce())
184-
->method('output')
185-
->willReturn($output);
186188
$this->requestMock->expects($this->any())
187189
->method('getParam')
188190
->willReturnMap(
@@ -206,20 +208,14 @@ public function testExecuteBackupFound()
206208
$this->fileFactoryMock->expects($this->once())
207209
->method('create')->with(
208210
$filename,
209-
null,
211+
['type' => 'filename', 'value' => $path . '/' . $filename],
210212
DirectoryList::VAR_DIR,
211213
'application/octet-stream',
212214
$size
213215
)
214216
->willReturn($this->responseMock);
215-
$this->resultRawMock->expects($this->once())
216-
->method('setContents')
217-
->with($output);
218-
$this->resultRawFactoryMock->expects($this->once())
219-
->method('create')
220-
->willReturn($this->resultRawMock);
221217

222-
$this->assertSame($this->resultRawMock, $this->downloadController->execute());
218+
$this->assertSame($this->responseMock, $this->downloadController->execute());
223219
}
224220

225221
/**

app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ public function __construct(
128128
$metadataPool,
129129
$tableMaintainer
130130
);
131-
132131
$this->stockItem = $stockItem
133132
?? ObjectManager::getInstance()->get(\Magento\CatalogInventory\Model\ResourceModel\Stock\Item::class);
134133
}
@@ -145,6 +144,17 @@ protected function _construct()
145144
$this->_selectionTable = $this->getTable('catalog_product_bundle_selection');
146145
}
147146

147+
/**
148+
* @inheritDoc
149+
*/
150+
public function _resetState(): void
151+
{
152+
parent::_resetState();
153+
$this->itemPrototype = null;
154+
$this->catalogRuleProcessor = null;
155+
$this->websiteScopePriceJoined = false;
156+
}
157+
148158
/**
149159
* Set store id for each collection item when collection was loaded.
150160
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
@@ -355,8 +365,6 @@ public function addPriceFilter($product, $searchMin, $useRegularPrice = false)
355365
* Get Catalog Rule Processor.
356366
*
357367
* @return \Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor
358-
*
359-
* @deprecated 100.2.0
360368
*/
361369
private function getCatalogRuleProcessor()
362370
{

app/code/Magento/Captcha/Test/Mftf/Test/StorefrontCaptchaOnOnepageCheckoutPyamentTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<group value="storefront_captcha_enabled"/>
2222
</annotations>
2323
<before>
24+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
2425
<!-- Create Simple Product -->
2526
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
2627
<field key="price">20</field>
@@ -62,6 +63,7 @@
6263

6364
<!-- Delete customer -->
6465
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
66+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
6567
</after>
6668

6769
<!-- Reindex and flush cache -->

app/code/Magento/Catalog/Controller/Adminhtml/Product/NewAction.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
8+
79
namespace Magento\Catalog\Controller\Adminhtml\Product;
810

9-
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
10-
use Magento\Backend\App\Action;
1111
use Magento\Catalog\Controller\Adminhtml\Product;
12+
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
1213
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\RegexValidator;
1315

1416
class NewAction extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpGetActionInterface
1517
{
1618
/**
1719
* @var Initialization\StockDataFilter
1820
* @deprecated 101.0.0
21+
* @see Initialization\StockDataFilter
1922
*/
2023
protected $stockFilter;
2124

@@ -30,23 +33,32 @@ class NewAction extends \Magento\Catalog\Controller\Adminhtml\Product implements
3033
protected $resultForwardFactory;
3134

3235
/**
33-
* @param Action\Context $context
36+
* @var RegexValidator
37+
*/
38+
private RegexValidator $regexValidator;
39+
40+
/**
41+
* @param Context $context
3442
* @param Builder $productBuilder
3543
* @param Initialization\StockDataFilter $stockFilter
3644
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
3745
* @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
46+
* @param RegexValidator|null $regexValidator
3847
*/
3948
public function __construct(
4049
\Magento\Backend\App\Action\Context $context,
4150
Product\Builder $productBuilder,
4251
Initialization\StockDataFilter $stockFilter,
4352
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
44-
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
53+
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
54+
RegexValidator $regexValidator = null
4555
) {
4656
$this->stockFilter = $stockFilter;
4757
parent::__construct($context, $productBuilder);
4858
$this->resultPageFactory = $resultPageFactory;
4959
$this->resultForwardFactory = $resultForwardFactory;
60+
$this->regexValidator = $regexValidator
61+
?: ObjectManager::getInstance()->get(RegexValidator::class);
5062
}
5163

5264
/**
@@ -56,6 +68,11 @@ public function __construct(
5668
*/
5769
public function execute()
5870
{
71+
$typeId = $this->getRequest()->getParam('type');
72+
if (!$this->regexValidator->validateParamRegex($typeId)) {
73+
return $this->resultForwardFactory->create()->forward('noroute');
74+
}
75+
5976
if (!$this->getRequest()->getParam('set')) {
6077
return $this->resultForwardFactory->create()->forward('noroute');
6178
}

app/code/Magento/Catalog/Model/Layer/Resolver.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99

1010
namespace Magento\Catalog\Model\Layer;
1111

12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
13+
1214
/**
1315
* Layer Resolver
1416
*
1517
* @api
1618
*/
17-
class Resolver
19+
class Resolver implements ResetAfterRequestInterface
1820
{
19-
const CATALOG_LAYER_CATEGORY = 'category';
20-
const CATALOG_LAYER_SEARCH = 'search';
21+
public const CATALOG_LAYER_CATEGORY = 'category';
22+
public const CATALOG_LAYER_SEARCH = 'search';
2123

2224
/**
2325
* Catalog view layer models list
@@ -79,4 +81,12 @@ public function get()
7981
}
8082
return $this->layer;
8183
}
84+
85+
/**
86+
* @inheritDoc
87+
*/
88+
public function _resetState(): void
89+
{
90+
$this->layer = null;
91+
}
8292
}

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Catalog\Model\Product\Gallery;
88

9+
use Magento\AwsS3\Driver\AwsS3;
910
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
1011
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
1112
use Magento\Catalog\Api\ProductRepositoryInterface;
@@ -287,10 +288,18 @@ private function getImageContent($product, $entry): ImageContentInterface
287288
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
288289
$path = $mediaDirectory->getAbsolutePath($product->getMediaConfig()->getMediaPath($entry->getFile()));
289290
$fileName = $this->file->getPathInfo($path)['basename'];
290-
$imageFileContent = $mediaDirectory->getDriver()->fileGetContents($path);
291+
$fileDriver = $mediaDirectory->getDriver();
292+
$imageFileContent = $fileDriver->fileGetContents($path);
293+
294+
if ($fileDriver instanceof AwsS3) {
295+
$remoteMediaMimeType = $fileDriver->getMetadata($path);
296+
$mediaMimeType = $remoteMediaMimeType['mimetype'];
297+
} else {
298+
$mediaMimeType = $this->mime->getMimeType($path);
299+
}
291300
return $this->imageContentInterface->create()
292301
->setName($fileName)
293302
->setBase64EncodedData(base64_encode($imageFileContent))
294-
->setType($this->mime->getMimeType($path));
303+
->setType($mediaMimeType);
295304
}
296305
}

app/code/Magento/Catalog/Model/Product/Media/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Config implements ConfigInterface, ResetAfterRequestInterface
3030
private $attributeHelper;
3131

3232
/**
33-
* @var string[]
33+
* @var string[]|null
3434
*/
3535
private $mediaAttributeCodes;
3636

@@ -206,6 +206,6 @@ private function getAttributeHelper()
206206
*/
207207
public function _resetState(): void
208208
{
209-
$this->mediaAttributeCodes = [];
209+
$this->mediaAttributeCodes = null;
210210
}
211211
}

app/code/Magento/Catalog/Model/ResourceModel/Category/Collection.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ protected function _construct()
137137
$this->_init(Category::class, \Magento\Catalog\Model\ResourceModel\Category::class);
138138
}
139139

140+
/**
141+
* @inheritDoc
142+
*/
143+
public function _resetState(): void
144+
{
145+
parent::_resetState();
146+
$this->_productTable = null;
147+
$this->_productStoreId = null;
148+
$this->_productWebsiteTable = null;
149+
$this->_loadWithProductCount = false;
150+
}
151+
140152
/**
141153
* Add Id filter
142154
*

app/code/Magento/Catalog/Model/ResourceModel/Collection/AbstractCollection.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ public function __construct(
7676
);
7777
}
7878

79+
/**
80+
* @inheritDoc
81+
*/
82+
public function _resetState(): void
83+
{
84+
parent::_resetState();
85+
$this->_storeId = null;
86+
}
87+
7988
/**
8089
* Retrieve Entity Primary Key
8190
*

0 commit comments

Comments
 (0)