Skip to content

Commit

Permalink
Merge pull request #143 from magento-commerce/1.1.39-release
Browse files Browse the repository at this point in the history
1.1.39 Release
  • Loading branch information
katmoon authored Oct 5, 2023
2 parents f1f193f + 04fb33c commit 4d7fe16
Show file tree
Hide file tree
Showing 21 changed files with 1,741 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/quality-patches",
"description": "Provides quality patches for AdobeCommerce & Magento OpenSource",
"type": "magento2-component",
"version": "1.1.38",
"version": "1.1.39",
"license": "proprietary",
"repositories": {
"repo": {
Expand Down
2 changes: 1 addition & 1 deletion patches-info.json

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions patches/commerce/ACSD-53704_2.4.5-p1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
diff --git a/vendor/magento/module-reward/Model/ResourceModel/Reward/History.php b/vendor/magento/module-reward/Model/ResourceModel/Reward/History.php
index 12e818b..60ea12e 100644
--- a/vendor/magento/module-reward/Model/ResourceModel/Reward/History.php
+++ b/vendor/magento/module-reward/Model/ResourceModel/Reward/History.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Reward\Model\ResourceModel\Reward;

+use Magento\Framework\Exception\LocalizedException;
use Magento\Reward\Model\Reward\History as ModelRewardHistory;

/**
@@ -213,6 +214,7 @@ class History extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
* @param string $expiryType Expiry calculation (static or dynamic)
* @param int $limit Limitation for records expired selection
* @return $this
+ * @throws LocalizedException|\Zend_Db_Statement_Exception
*/
public function expirePoints($websiteId, $expiryType, $limit)
{
@@ -222,8 +224,12 @@ class History extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb

$select = $connection->select()->from(
$this->getMainTable()
+ )->joinInner(
+ ['reward' => $this->getTable('magento_reward')],
+ 'reward.reward_id = ' . $this->getMainTable() . '.reward_id',
+ []
)->where(
- 'website_id = :website_id'
+ $this->getMainTable() . '.website_id = :website_id'
)->where(
"{$field} < :time_now"
)->where(
@@ -237,6 +243,10 @@ class History extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
)->limit(
(int)$limit
);
+ $select->columns(
+ [$this->getMainTable() . '.*',
+ 'current_balance' => 'reward.points_balance']
+ );
$bind = [':website_id' => $websiteId, ':time_now' => $now];
$duplicates = [];
$expiredAmounts = [];
@@ -255,8 +265,10 @@ class History extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
}
$expiredAmount = $row['points_delta'] - $row['points_used'];
$row['points_delta'] = -$expiredAmount;
+ $row['points_balance'] = $row['current_balance'] - abs($expiredAmount);
$row['points_used'] = 0;
$expiredAmounts[$row['reward_id']] += $expiredAmount;
+ unset($row['current_balance']);
$duplicates[] = $row;
}

@@ -268,8 +280,8 @@ class History extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
}
$bind = [
'points_balance' => $connection->getCheckSql(
- "points_balance > {$expired}",
- "points_balance-{$expired}",
+ "points_balance > " . abs($expired),
+ "points_balance-" . abs($expired),
0
),
];
25 changes: 25 additions & 0 deletions patches/commerce/ACSD-54026_1.3.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/vendor/magento/module-company-graph-ql/Model/Resolver/UpdateCompanyRole.php b/vendor/magento/module-company-graph-ql/Model/Resolver/UpdateCompanyRole.php
index 5d52f53758..35a1c5c64d 100644
--- a/vendor/magento/module-company-graph-ql/Model/Resolver/UpdateCompanyRole.php
+++ b/vendor/magento/module-company-graph-ql/Model/Resolver/UpdateCompanyRole.php
@@ -13,6 +13,7 @@ use Magento\CompanyGraphQl\Model\Company\Role\PermissionsFormatter;
use Magento\CompanyGraphQl\Model\Company\Role\UpdateRole;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
+use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Query\Uid;
@@ -84,6 +85,12 @@ class UpdateCompanyRole implements ResolverInterface
*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
+ if (false === $context->getExtensionAttributes()->getIsCustomer()) {
+ throw new GraphQlAuthenticationException(
+ __('The current customer isn\'t authorized.')
+ );
+ }
+
$this->resolverAccess->isAllowed($this->allowedResources);

if (empty($args['input']) || !is_array($args['input'])) {
61 changes: 61 additions & 0 deletions patches/commerce/ACSD-54776_2.4.6-p1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
diff --git a/vendor/magento/module-staging/Model/Entity/Update/Action/Save/SaveAction.php b/vendor/magento/module-staging/Model/Entity/Update/Action/Save/SaveAction.php
index 0fa78c23008..60f589eee37 100644
--- a/vendor/magento/module-staging/Model/Entity/Update/Action/Save/SaveAction.php
+++ b/vendor/magento/module-staging/Model/Entity/Update/Action/Save/SaveAction.php
@@ -29,6 +29,7 @@ class SaveAction implements ActionInterface
/**
* @var UpdateService
* @deprecated 100.1.0 Since functionality if this service was implemented in SaveAction class
+ * @see nothing
*/
private $updateService;

@@ -118,22 +119,19 @@ class SaveAction implements ActionInterface

if (!isset($stagingData['update_id']) || empty($stagingData['update_id'])) {
$update = $this->createUpdate($stagingData);
+ $entity = $this->entityHydrator->hydrate($entityData);
$this->versionManager->setCurrentVersionId($update->getId());
-
- $this->schedule($entityData, $update->getId());
+ $this->entityStaging->schedule($entity, $update->getId(), []);
} else {
$update = $this->updateRepository->get($stagingData['update_id']);
$this->versionManager->setCurrentVersionId($update->getId());

$update = $this->editUpdate($stagingData);

- $this->schedule(
- $entityData,
- $update->getId(),
- [
- 'origin_in' => $stagingData['update_id'],
- ]
- );
+ $entity = $this->entityHydrator->hydrate($entityData);
+ $this->entityStaging->schedule($entity, $update->getId(), [
+ 'origin_in' => $stagingData['update_id'],
+ ]);
}

return true;
@@ -200,19 +198,4 @@ class SaveAction implements ActionInterface

return $update;
}
-
- /**
- * Set schedule for requested entity
- *
- * @param array $entityData
- * @param int $version
- * @param array $arguments
- * @return void
- */
- private function schedule(array $entityData, $version, array $arguments = [])
- {
- $entity = $this->entityHydrator->hydrate($entityData);
-
- $this->entityStaging->schedule($entity, $version, $arguments);
- }
}
227 changes: 227 additions & 0 deletions patches/os/ACSD-47657_2.4.4.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
diff --git a/vendor/magento/module-aws-s3/Driver/AwsS3Factory.php b/vendor/magento/module-aws-s3/Driver/AwsS3Factory.php
index 66c95e97ace0..b1cec93ed8f7 100644
--- a/vendor/magento/module-aws-s3/Driver/AwsS3Factory.php
+++ b/vendor/magento/module-aws-s3/Driver/AwsS3Factory.php
@@ -54,6 +54,11 @@ class AwsS3Factory implements DriverFactoryInterface
*/
private $cachePrefix;

+ /**
+ * @var CachedCredentialsProvider
+ */
+ private $cachedCredentialsProvider;
+
/**
* @param ObjectManagerInterface $objectManager
* @param Config $config
@@ -61,6 +66,7 @@ class AwsS3Factory implements DriverFactoryInterface
* @param CacheInterfaceFactory $cacheInterfaceFactory
* @param CachedAdapterInterfaceFactory $cachedAdapterInterfaceFactory
* @param string|null $cachePrefix
+ * @param CachedCredentialsProvider|null $cachedCredentialsProvider
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -68,7 +74,8 @@ public function __construct(
MetadataProviderInterfaceFactory $metadataProviderFactory,
CacheInterfaceFactory $cacheInterfaceFactory,
CachedAdapterInterfaceFactory $cachedAdapterInterfaceFactory,
- string $cachePrefix = null
+ string $cachePrefix = null,
+ ?CachedCredentialsProvider $cachedCredentialsProvider = null,
) {
$this->objectManager = $objectManager;
$this->config = $config;
@@ -76,6 +83,8 @@ public function __construct(
$this->cacheInterfaceFactory = $cacheInterfaceFactory;
$this->cachedAdapterInterfaceFactory = $cachedAdapterInterfaceFactory;
$this->cachePrefix = $cachePrefix;
+ $this->cachedCredentialsProvider = $cachedCredentialsProvider ??
+ $this->objectManager->get(CachedCredentialsProvider::class);
}

/**
@@ -94,18 +103,19 @@ public function create(): RemoteDriverInterface
}

/**
- * @inheritDoc
+ * Prepare config for S3Client
+ *
+ * @param array $config
+ * @return array
+ * @throws DriverException
*/
- public function createConfigured(
- array $config,
- string $prefix,
- string $cacheAdapter = '',
- array $cacheConfig = []
- ): RemoteDriverInterface {
+ private function prepareConfig(array $config)
+ {
$config['version'] = 'latest';

if (empty($config['credentials']['key']) || empty($config['credentials']['secret'])) {
- unset($config['credentials']);
+ //Access keys were not provided; request token from AWS config (local or EC2) and cache result
+ $config['credentials'] = $this->cachedCredentialsProvider->get();
}

if (empty($config['bucket']) || empty($config['region'])) {
@@ -120,6 +130,19 @@ public function createConfigured(
$config['use_path_style_endpoint'] = boolval($config['path_style']);
}

+ return $config;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function createConfigured(
+ array $config,
+ string $prefix,
+ string $cacheAdapter = '',
+ array $cacheConfig = []
+ ): RemoteDriverInterface {
+ $config = $this->prepareConfig($config);
$client = new S3Client($config);
$adapter = new AwsS3V3Adapter($client, $config['bucket'], $prefix);
$cache = $this->cacheInterfaceFactory->create(
diff --git a/vendor/magento/module-aws-s3/Driver/CachedCredentialsProvider.php b/vendor/magento/module-aws-s3/Driver/CachedCredentialsProvider.php
new file mode 100644
index 000000000000..0137284358bd
--- /dev/null
+++ b/vendor/magento/module-aws-s3/Driver/CachedCredentialsProvider.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+declare(strict_types=1);
+
+namespace Magento\AwsS3\Driver;
+
+use Aws\Credentials\CredentialProvider;
+
+class CachedCredentialsProvider
+{
+ /**
+ * @var CredentialsCache
+ */
+ private $magentoCacheAdapter;
+
+ /**
+ * @param CredentialsCache $magentoCacheAdapter
+ */
+ public function __construct(CredentialsCache $magentoCacheAdapter)
+ {
+ $this->magentoCacheAdapter = $magentoCacheAdapter;
+ }
+
+ /**
+ * Provides cache mechanism to retrieve and store AWS credentials
+ *
+ * @return callable
+ */
+ public function get()
+ {
+ //phpcs:ignore Magento2.Functions.DiscouragedFunction
+ return call_user_func(
+ [CredentialProvider::class, 'cache'],
+ //phpcs:ignore Magento2.Functions.DiscouragedFunction
+ call_user_func([CredentialProvider::class, 'defaultProvider']),
+ $this->magentoCacheAdapter
+ );
+ }
+}
diff --git a/vendor/magento/module-aws-s3/Driver/CredentialsCache.php b/vendor/magento/module-aws-s3/Driver/CredentialsCache.php
new file mode 100644
index 000000000000..337e9d2a2acf
--- /dev/null
+++ b/vendor/magento/module-aws-s3/Driver/CredentialsCache.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+declare(strict_types=1);
+
+namespace Magento\AwsS3\Driver;
+
+use Aws\CacheInterface;
+use Aws\Credentials\CredentialsFactory;
+use Magento\Framework\App\CacheInterface as MagentoCacheInterface;
+use Magento\Framework\Serialize\Serializer\Json;
+
+/** Cache Adapter for AWS credentials */
+class CredentialsCache implements CacheInterface
+{
+ /**
+ * @var MagentoCacheInterface
+ */
+ private $magentoCache;
+
+ /**
+ * @var Json
+ */
+ private $json;
+
+ /**
+ * @var CredentialsFactory
+ */
+ private $credentialsFactory;
+
+ /**
+ * @param MagentoCacheInterface $magentoCache
+ * @param CredentialsFactory $credentialsFactory
+ * @param Json $json
+ */
+ public function __construct(MagentoCacheInterface $magentoCache, CredentialsFactory $credentialsFactory, Json $json)
+ {
+ $this->magentoCache = $magentoCache;
+ $this->credentialsFactory = $credentialsFactory;
+ $this->json = $json;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get($key)
+ {
+ $value = $this->magentoCache->load($key);
+
+ if (!is_string($value)) {
+ return null;
+ }
+
+ $result = $this->json->unserialize($value);
+ try {
+ return $this->credentialsFactory->create($result);
+ } catch (\Exception $e) {
+ return $result;
+ }
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function set($key, $value, $ttl = 0)
+ {
+ if (method_exists($value, 'toArray')) {
+ $value = $value->toArray();
+ }
+ $this->magentoCache->save($this->json->serialize($value), $key, [], $ttl);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function remove($key)
+ {
+ $this->magentoCache->remove($key);
+ }
+}
Loading

0 comments on commit 4d7fe16

Please sign in to comment.