Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.4-develop' into AC-7499
Browse files Browse the repository at this point in the history
  • Loading branch information
glo17680 committed Jun 15, 2023
2 parents dc5ca39 + adc4105 commit 412bb5a
Show file tree
Hide file tree
Showing 156 changed files with 2,029 additions and 887 deletions.
10 changes: 10 additions & 0 deletions app/code/Magento/Backend/Model/Auth/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ public function __construct(
);
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
parent::_resetState();
$this->_isFirstAfterLogin = null;
$this->acl = null;
}

/**
* Refresh ACL resources stored in session
*
Expand Down
13 changes: 12 additions & 1 deletion app/code/Magento/Backend/Model/Session/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ public function __construct(
}
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
parent::_resetState();
$this->_quote = null;
$this->_store = null;
$this->_order = null;
}

/**
* Retrieve quote model object
*
Expand All @@ -154,7 +165,7 @@ public function getQuote()
$this->_quote->setCustomerGroupId($customerGroupId);
$this->_quote->setIsActive(false);
$this->_quote->setStoreId($this->getStoreId());

$this->quoteRepository->save($this->_quote);
$this->setQuoteId($this->_quote->getId());
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
Expand Down
12 changes: 4 additions & 8 deletions app/code/Magento/Backup/Controller/Adminhtml/Index/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
*/
namespace Magento\Backup\Controller\Adminhtml\Index;

use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\Filesystem\DirectoryList;

class Download extends \Magento\Backup\Controller\Adminhtml\Index
class Download extends \Magento\Backup\Controller\Adminhtml\Index implements HttpGetActionInterface
{
/**
* @var \Magento\Framework\Controller\Result\RawFactory
Expand Down Expand Up @@ -66,17 +67,12 @@ public function execute()

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

$this->_fileFactory->create(
return $this->_fileFactory->create(
$fileName,
null,
['type' => 'filename', 'value' => $backup->getPath() . DIRECTORY_SEPARATOR . $backup->getFileName()],
DirectoryList::VAR_DIR,
'application/octet-stream',
$backup->getSize()
);

/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
$resultRaw = $this->resultRawFactory->create();
$resultRaw->setContents($backup->output());
return $resultRaw;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected function setUp(): void
->getMock();
$this->backupModelMock = $this->getMockBuilder(Backup::class)
->disableOriginalConstructor()
->setMethods(['getTime', 'exists', 'getSize', 'output'])
->setMethods(['getTime', 'exists', 'getSize', 'output', 'getPath', 'getFileName'])
->getMock();
$this->dataHelperMock = $this->getMockBuilder(Data::class)
->disableOriginalConstructor()
Expand Down Expand Up @@ -169,8 +169,13 @@ public function testExecuteBackupFound()
$type = 'db';
$filename = 'filename';
$size = 10;
$output = 'test';

$path = 'testpath';
$this->backupModelMock->expects($this->atLeastOnce())
->method('getPath')
->willReturn($path);
$this->backupModelMock->expects($this->atLeastOnce())
->method('getFileName')
->willReturn($filename);
$this->backupModelMock->expects($this->atLeastOnce())
->method('getTime')
->willReturn($time);
Expand All @@ -180,9 +185,6 @@ public function testExecuteBackupFound()
$this->backupModelMock->expects($this->atLeastOnce())
->method('getSize')
->willReturn($size);
$this->backupModelMock->expects($this->atLeastOnce())
->method('output')
->willReturn($output);
$this->requestMock->expects($this->any())
->method('getParam')
->willReturnMap(
Expand All @@ -206,20 +208,14 @@ public function testExecuteBackupFound()
$this->fileFactoryMock->expects($this->once())
->method('create')->with(
$filename,
null,
['type' => 'filename', 'value' => $path . '/' . $filename],
DirectoryList::VAR_DIR,
'application/octet-stream',
$size
)
->willReturn($this->responseMock);
$this->resultRawMock->expects($this->once())
->method('setContents')
->with($output);
$this->resultRawFactoryMock->expects($this->once())
->method('create')
->willReturn($this->resultRawMock);

$this->assertSame($this->resultRawMock, $this->downloadController->execute());
$this->assertSame($this->responseMock, $this->downloadController->execute());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public function __construct(
$metadataPool,
$tableMaintainer
);

$this->stockItem = $stockItem
?? ObjectManager::getInstance()->get(\Magento\CatalogInventory\Model\ResourceModel\Stock\Item::class);
}
Expand All @@ -145,6 +144,17 @@ protected function _construct()
$this->_selectionTable = $this->getTable('catalog_product_bundle_selection');
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
parent::_resetState();
$this->itemPrototype = null;
$this->catalogRuleProcessor = null;
$this->websiteScopePriceJoined = false;
}

/**
* Set store id for each collection item when collection was loaded.
* phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
Expand Down Expand Up @@ -355,8 +365,6 @@ public function addPriceFilter($product, $searchMin, $useRegularPrice = false)
* Get Catalog Rule Processor.
*
* @return \Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor
*
* @deprecated 100.2.0
*/
private function getCatalogRuleProcessor()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<group value="storefront_captcha_enabled"/>
</annotations>
<before>
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
<!-- Create Simple Product -->
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
<field key="price">20</field>
Expand Down Expand Up @@ -62,6 +63,7 @@

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

<!-- Reindex and flush cache -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Controller\Adminhtml\Product;

use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\App\Action;
use Magento\Catalog\Controller\Adminhtml\Product;
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\RegexValidator;

class NewAction extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpGetActionInterface
{
/**
* @var Initialization\StockDataFilter
* @deprecated 101.0.0
* @see Initialization\StockDataFilter
*/
protected $stockFilter;

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

/**
* @param Action\Context $context
* @var RegexValidator
*/
private RegexValidator $regexValidator;

/**
* @param Context $context
* @param Builder $productBuilder
* @param Initialization\StockDataFilter $stockFilter
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
* @param RegexValidator|null $regexValidator
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
Product\Builder $productBuilder,
Initialization\StockDataFilter $stockFilter,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
RegexValidator $regexValidator = null
) {
$this->stockFilter = $stockFilter;
parent::__construct($context, $productBuilder);
$this->resultPageFactory = $resultPageFactory;
$this->resultForwardFactory = $resultForwardFactory;
$this->regexValidator = $regexValidator
?: ObjectManager::getInstance()->get(RegexValidator::class);
}

/**
Expand All @@ -56,6 +68,11 @@ public function __construct(
*/
public function execute()
{
$typeId = $this->getRequest()->getParam('type');
if (!$this->regexValidator->validateParamRegex($typeId)) {
return $this->resultForwardFactory->create()->forward('noroute');
}

if (!$this->getRequest()->getParam('set')) {
return $this->resultForwardFactory->create()->forward('noroute');
}
Expand Down
16 changes: 13 additions & 3 deletions app/code/Magento/Catalog/Model/Layer/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@

namespace Magento\Catalog\Model\Layer;

use Magento\Framework\ObjectManager\ResetAfterRequestInterface;

/**
* Layer Resolver
*
* @api
*/
class Resolver
class Resolver implements ResetAfterRequestInterface
{
const CATALOG_LAYER_CATEGORY = 'category';
const CATALOG_LAYER_SEARCH = 'search';
public const CATALOG_LAYER_CATEGORY = 'category';
public const CATALOG_LAYER_SEARCH = 'search';

/**
* Catalog view layer models list
Expand Down Expand Up @@ -79,4 +81,12 @@ public function get()
}
return $this->layer;
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
$this->layer = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Magento\Catalog\Model\Product\Gallery;

use Magento\AwsS3\Driver\AwsS3;
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
Expand Down Expand Up @@ -287,10 +288,18 @@ private function getImageContent($product, $entry): ImageContentInterface
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$path = $mediaDirectory->getAbsolutePath($product->getMediaConfig()->getMediaPath($entry->getFile()));
$fileName = $this->file->getPathInfo($path)['basename'];
$imageFileContent = $mediaDirectory->getDriver()->fileGetContents($path);
$fileDriver = $mediaDirectory->getDriver();
$imageFileContent = $fileDriver->fileGetContents($path);

if ($fileDriver instanceof AwsS3) {
$remoteMediaMimeType = $fileDriver->getMetadata($path);
$mediaMimeType = $remoteMediaMimeType['mimetype'];
} else {
$mediaMimeType = $this->mime->getMimeType($path);
}
return $this->imageContentInterface->create()
->setName($fileName)
->setBase64EncodedData(base64_encode($imageFileContent))
->setType($this->mime->getMimeType($path));
->setType($mediaMimeType);
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Catalog/Model/Product/Media/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Config implements ConfigInterface, ResetAfterRequestInterface
private $attributeHelper;

/**
* @var string[]
* @var string[]|null
*/
private $mediaAttributeCodes;

Expand Down Expand Up @@ -206,6 +206,6 @@ private function getAttributeHelper()
*/
public function _resetState(): void
{
$this->mediaAttributeCodes = [];
$this->mediaAttributeCodes = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ protected function _construct()
$this->_init(Category::class, \Magento\Catalog\Model\ResourceModel\Category::class);
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
parent::_resetState();
$this->_productTable = null;
$this->_productStoreId = null;
$this->_productWebsiteTable = null;
$this->_loadWithProductCount = false;
}

/**
* Add Id filter
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ public function __construct(
);
}

/**
* @inheritDoc
*/
public function _resetState(): void
{
parent::_resetState();
$this->_storeId = null;
}

/**
* Retrieve Entity Primary Key
*
Expand Down

0 comments on commit 412bb5a

Please sign in to comment.