Skip to content

Commit

Permalink
Merge branch '2.4-develop' into cache-clean-remove
Browse files Browse the repository at this point in the history
  • Loading branch information
engcom-Hotel committed Dec 1, 2020
2 parents 6c2d07c + 479f304 commit 23ddcfc
Show file tree
Hide file tree
Showing 150 changed files with 2,324 additions and 480 deletions.
7 changes: 7 additions & 0 deletions app/code/Magento/Analytics/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@
<token/>
</general>
</analytics>
<system>
<media_storage_configuration>
<allowed_resources>
<analytics_folder>analytics</analytics_folder>
</allowed_resources>
</media_storage_configuration>
</system>
</default>
</config>
32 changes: 9 additions & 23 deletions app/code/Magento/Authorization/Model/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,30 @@
class Rules extends \Magento\Framework\Model\AbstractModel
{
/**
* Class constructor
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Authorization\Model\ResourceModel\Rules $resource
* @param \Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Authorization\Model\ResourceModel\Rules $resource,
\Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection,
array $data = []
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}

/**
* Class constructor
*
* @return void
* @inheritdoc
*/
protected function _construct()
{
$this->_init(\Magento\Authorization\Model\ResourceModel\Rules::class);
}

/**
* Obsolete method of update
*
* @return $this
* @deprecated Method was never implemented and used.
*/
public function update()
{
$this->getResource()->update($this);
// phpcs:disable Magento2.Functions.DiscouragedFunction
trigger_error('Method was never implemented and used.', E_USER_DEPRECATED);

return $this;
}

/**
* Save authorization rule relation
*
* @return $this
*/
public function saveRel()
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/AwsS3/Driver/AwsS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
* Resolves relative path.
*
* @param string $path Absolute path
* @param bool $fixPath
* @return string Relative path
*/
private function normalizeRelativePath(string $path, bool $fixPath = false): string
Expand Down Expand Up @@ -358,7 +359,7 @@ public function isFile($path): bool
return false;
}

$path = $this->normalizeRelativePath($path, true);;
$path = $this->normalizeRelativePath($path, true);

if ($this->adapter->has($path) && ($meta = $this->adapter->getMetadata($path))) {
return ($meta['type'] ?? null) === self::TYPE_FILE;
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/AwsS3/Driver/AwsS3Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public function createConfigured(
throw new DriverException(__('Bucket and region are required values'));
}

if (!empty($config['http_handler'])) {
$config['http_handler'] = $this->objectManager->create($config['http_handler'])($config);
}

$client = new S3Client($config);
$adapter = new AwsS3Adapter($client, $config['bucket'], $prefix);

Expand Down
61 changes: 61 additions & 0 deletions app/code/Magento/AwsS3/Model/HttpLoggerHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\AwsS3\Model;

use Aws\Handler\GuzzleV6\GuzzleHandler;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\MessageFormatter;
use GuzzleHttp\Middleware;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

final class HttpLoggerHandler
{
/**
* @var Filesystem\Directory\WriteInterface
*/
private $directory;

/**
* @var string
*/
private $file;

/**
* @param Filesystem $filesystem
* @param string $file
* @throws FileSystemException
*/
public function __construct(
Filesystem $filesystem,
$file = 'debug/s3.log'
) {
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$this->file = $file;
}

public function __invoke()
{
$this->directory->create(pathinfo($this->file, PATHINFO_DIRNAME));
$localStream = $this->directory->getDriver()->fileOpen($this->directory->getAbsolutePath($this->file), 'a');
$streamHandler = new StreamHandler($localStream, Logger::DEBUG, true, null, true);
$logger = new \Monolog\Logger('S3', [$streamHandler]);
$stack = HandlerStack::create();
$stack->push(
Middleware::log(
$logger,
new MessageFormatter('{code}:{method}:{target} {error}')
)
);
return new GuzzleHandler(new Client(['handler' => $stack]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

namespace Magento\Catalog\Block\Product\View\Options;

use Magento\Catalog\Pricing\Price\BasePrice;
use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;

/**
* Product options section abstract block.
Expand Down Expand Up @@ -55,24 +56,42 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template
*/
private $calculateCustomOptionCatalogRule;

/**
* @var CalculatorInterface
*/
private $calculator;

/**
* @var PriceCurrencyInterface
*/
private $priceCurrency;

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
* @param \Magento\Catalog\Helper\Data $catalogData
* @param array $data
* @param CalculateCustomOptionCatalogRule|null $calculateCustomOptionCatalogRule
* @param CalculatorInterface|null $calculator
* @param PriceCurrencyInterface|null $priceCurrency
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Pricing\Helper\Data $pricingHelper,
\Magento\Catalog\Helper\Data $catalogData,
array $data = [],
CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null,
CalculatorInterface $calculator = null,
PriceCurrencyInterface $priceCurrency = null
) {
$this->pricingHelper = $pricingHelper;
$this->_catalogHelper = $catalogData;
$this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule
?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
$this->calculator = $calculator
?? ObjectManager::getInstance()->get(CalculatorInterface::class);
$this->priceCurrency = $priceCurrency
?? ObjectManager::getInstance()->get(PriceCurrencyInterface::class);
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -188,7 +207,13 @@ protected function _formatPrice($value, $flag = true)
}

$context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true];
$optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
$optionAmount = $isPercent
? $this->calculator->getAmount(
$this->priceCurrency->roundPrice($value['pricing_value']),
$this->getProduct(),
null,
$context
) : $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
$priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount(
$optionAmount,
$customOptionPrice,
Expand Down
25 changes: 5 additions & 20 deletions app/code/Magento/Catalog/Model/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
namespace Magento\Catalog\Model\Product;

use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
use Magento\Catalog\Model\View\Asset\ImageFactory;
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Image as MagentoImage;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
use Magento\Framework\Filesystem\Driver\File as FilesystemDriver;

/**
* Image operations
Expand Down Expand Up @@ -202,11 +200,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
*/
private $serializer;

/**
* @var FilesystemDriver
*/
private $filesystemDriver;

/**
* Constructor
*
Expand All @@ -227,7 +220,6 @@ class Image extends \Magento\Framework\Model\AbstractModel
* @param array $data
* @param SerializerInterface $serializer
* @param ParamsBuilder $paramsBuilder
* @param FilesystemDriver $filesystemDriver
* @throws \Magento\Framework\Exception\FileSystemException
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
Expand All @@ -249,8 +241,7 @@ public function __construct(
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
SerializerInterface $serializer = null,
ParamsBuilder $paramsBuilder = null,
FilesystemDriver $filesystemDriver = null
ParamsBuilder $paramsBuilder = null
) {
$this->_storeManager = $storeManager;
$this->_catalogProductMediaConfig = $catalogProductMediaConfig;
Expand All @@ -265,7 +256,6 @@ public function __construct(
$this->viewAssetPlaceholderFactory = $viewAssetPlaceholderFactory;
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
$this->paramsBuilder = $paramsBuilder ?: ObjectManager::getInstance()->get(ParamsBuilder::class);
$this->filesystemDriver = $filesystemDriver ?: ObjectManager::getInstance()->get(FilesystemDriver::class);
}

/**
Expand Down Expand Up @@ -675,12 +665,7 @@ public function getDestinationSubdir()
public function isCached()
{
$path = $this->imageAsset->getPath();
try {
$isCached = is_array($this->loadImageInfoFromCache($path)) || $this->filesystemDriver->isExists($path);
} catch (FileSystemException $e) {
$isCached = false;
}
return $isCached;
return is_array($this->loadImageInfoFromCache($path)) || $this->_mediaDirectory->isExist($path);
}

/**
Expand Down Expand Up @@ -952,7 +937,7 @@ private function getImageSize($imagePath)
*/
private function saveImageInfoToCache(array $imageInfo, string $imagePath)
{
$imagePath = $this->cachePrefix . $imagePath;
$imagePath = $this->cachePrefix . $imagePath;
$this->_cacheManager->save(
$this->serializer->serialize($imageInfo),
$imagePath,
Expand All @@ -968,7 +953,7 @@ private function saveImageInfoToCache(array $imageInfo, string $imagePath)
*/
private function loadImageInfoFromCache(string $imagePath)
{
$imagePath = $this->cachePrefix . $imagePath;
$imagePath = $this->cachePrefix . $imagePath;
$cacheData = $this->_cacheManager->load($imagePath);
if (!$cacheData) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontCustomOptionCheckboxByPriceActionGroup">
<annotations>
<description>Validates that the provided price for Custom Option Checkbox is present on the Storefront Product page.</description>
</annotations>
<arguments>
<argument name="optionTitle" type="string" defaultValue="{{ProductOptionCheckbox.title}}"/>
<argument name="price" type="string" defaultValue="10"/>
</arguments>

<seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(optionTitle, price)}}" stepKey="checkPriceProductOptionCheckbox"/>
</actionGroup>
</actionGroups>
4 changes: 4 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@
<var key="sku" entityType="product" entityKey="sku" />
<requiredEntity type="product_option">ProductOptionDropDownWithLongValuesTitle</requiredEntity>
</entity>
<entity name="productWithCheckbox" type="product">
<var key="sku" entityType="product" entityKey="sku" />
<requiredEntity type="product_option">ProductOptionCheckbox</requiredEntity>
</entity>
<entity name="productWithDropdownOption" type="product">
<var key="sku" entityType="product" entityKey="sku" />
<requiredEntity type="product_option">ProductOptionValueDropdown</requiredEntity>
Expand Down
Loading

0 comments on commit 23ddcfc

Please sign in to comment.