Skip to content

Commit

Permalink
Merge pull request #8882 from magento-gl/spartans_pr_15042024
Browse files Browse the repository at this point in the history
[Spartans] Bugfixes Delivery
  • Loading branch information
sidolov authored Jun 5, 2024
2 parents 4745100 + f20e1d6 commit 0574ac2
Show file tree
Hide file tree
Showing 22 changed files with 453 additions and 29 deletions.
21 changes: 14 additions & 7 deletions app/code/Magento/Elasticsearch/etc/esconfig.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@
<xs:element name="config" type="configType" />
<xs:complexType name="configType" mixed="true">
<xs:choice maxOccurs="unbounded" minOccurs="1">
<xs:element name="stemmer" type="mixedDataType" />
<xs:element name="stopwords_file" type="mixedDataType" />
<xs:element name="stemmer" type="stemmerDataType" />
<xs:element name="stopwords_file" type="stopwordsDataType" />
</xs:choice>
</xs:complexType>
<xs:complexType name="mixedDataType">
<xs:choice maxOccurs="unbounded" minOccurs="1">
<xs:element type="xs:string" name="default" minOccurs="1" maxOccurs="1" />
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
</xs:choice>
<xs:complexType name="stemmerDataType">
<xs:sequence>
<xs:element type="xs:string" name="type" minOccurs="1" maxOccurs="1"/>
<xs:element type="xs:string" name="default" minOccurs="1" maxOccurs="1"/>
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="stopwordsDataType">
<xs:sequence>
<xs:element type="xs:string" name="default" minOccurs="1" maxOccurs="1"/>
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
4 changes: 2 additions & 2 deletions app/code/Magento/GraphQl/Controller/GraphQl.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ public function dispatch(RequestInterface $request): ResponseInterface
$result = [];

$schema = null;
$query = $data['query'] ?? '';
try {
/** @var Http $request */
$this->requestProcessor->validateRequest($request);
$query = $data['query'] ?? '';
$parsedQuery = $this->queryParser->parse($query);
$data['parsedQuery'] = $parsedQuery;

Expand All @@ -216,7 +216,7 @@ public function dispatch(RequestInterface $request): ResponseInterface
$jsonResult->renderResult($this->httpResponse);

// log information about the query, unless it is an introspection query
if (!isset($data['query']) || strpos($data['query'], 'IntrospectionQuery') === false) {
if (strpos($query, 'IntrospectionQuery') === false) {
$queryInformation = $this->logDataHelper->getLogData($request, $data, $schema, $this->httpResponse);
$this->loggerPool->execute($queryInformation);
}
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/GraphQl/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<item name="graphql_type" xsi:type="object">Magento\Framework\GraphQl\Config\Element\TypeFactory</item>
<item name="graphql_input" xsi:type="object">Magento\Framework\GraphQl\Config\Element\InputFactory</item>
<item name="graphql_enum" xsi:type="object">Magento\Framework\GraphQl\Config\Element\EnumFactory</item>
<item name="graphql_scalar" xsi:type="object">Magento\Framework\GraphQl\Config\Element\ScalarFactory</item>
</argument>
</arguments>
</type>
Expand Down Expand Up @@ -69,6 +70,7 @@
<item name="Magento\Framework\GraphQl\Config\Element\InterfaceType" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Output\OutputInterfaceObject</item>
<item name="Magento\Framework\GraphQl\Config\Element\UnionType" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Output\OutputUnionObject</item>
<item name="Magento\Framework\GraphQl\Config\Element\Enum" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Enum\Enum</item>
<item name="Magento\Framework\GraphQl\Config\Element\Scalar" xsi:type="string">Magento\Framework\GraphQl\Schema\Type\Scalar\Scalar</item>
</argument>
</arguments>
</type>
Expand All @@ -95,6 +97,7 @@
<item name="object_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\ObjectType</item>
<item name="input_object_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\InputObjectType</item>
<item name="interface_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\InterfaceType</item>
<item name="scalar_type" xsi:type="object">Magento\Framework\GraphQlSchemaStitching\GraphQlReader\Reader\ScalarType</item>
</argument>
</arguments>
</type>
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/GraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ directive @typeResolver(class: String="") on UNION

directive @cache(cacheIdentity: String="" cacheable: Boolean=true) on QUERY

directive @implementation(class: String="") on SCALAR
| OBJECT

type Query {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ private function processValidationResult($validationResult, $resultBlock)

if ($import->getProcessedRowsCount()) {
if ($validationResult) {
$this->addMessageForValidResult($resultBlock);
$totalError = $errorAggregator->getErrorsCount();
$totalRows = $import->getProcessedRowsCount();
$this->addMessageForValidResult($resultBlock, $totalError, $totalRows);
} else {
$resultBlock->addError(
__('Data validation failed. Please fix the following errors and upload the file again.')
Expand Down Expand Up @@ -154,12 +156,14 @@ private function addMessageToSkipErrors(Result $resultBlock)
* 2. Add message for case when imported data was checked and result is valid, but import is not allowed.
*
* @param Result $resultBlock
* @param Import $totalError
* @param Import $totalRows
* @return void
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function addMessageForValidResult(Result $resultBlock)
private function addMessageForValidResult(Result $resultBlock, $totalError, $totalRows)
{
if ($this->getImport()->isImportAllowed()) {
if ($this->getImport()->isImportAllowed() && $totalRows > $totalError) {
$resultBlock->addSuccess(__('File is valid! To start import process press "Import" button'), true);
} else {
$resultBlock->addError(__('The file is valid, but we can\'t import it for some reason.'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,45 @@

namespace Magento\ImportExport\Plugin;

use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Indexer\DeferredCacheCleanerInterface;
use Magento\ImportExport\Model\Import;

class DeferCacheCleaningUntilImportIsComplete
{
private const BEHAVIOR_ADD_UPDATE = 'add_update';
private const ENTITY_CUSTOMER = 'customer';
private const CACHE_TYPE_GRAPHQL_QUERY_RESOLVER_RESULT = 'graphql_query_resolver_result';

/**
* @var DeferredCacheCleanerInterface
*/
private $cacheCleaner;

/**
* @var TypeListInterface
*/
private $cacheTypeList;

/**
* @var RequestInterface
*/
private $request;

/**
* @param DeferredCacheCleanerInterface $cacheCleaner
* @param TypeListInterface $cacheTypeList
* @param RequestInterface $request
*/
public function __construct(DeferredCacheCleanerInterface $cacheCleaner)
{
public function __construct(
DeferredCacheCleanerInterface $cacheCleaner,
TypeListInterface $cacheTypeList,
RequestInterface $request
) {
$this->cacheCleaner = $cacheCleaner;
$this->cacheTypeList = $cacheTypeList;
$this->request = $request;
}

/**
Expand All @@ -47,6 +70,13 @@ public function beforeImportSource(Import $subject): void
*/
public function afterImportSource(Import $subject, bool $result): bool
{
$behavior = $this->request->getParam('behavior');
$entity = $this->request->getParam('entity');

if ($behavior === self::BEHAVIOR_ADD_UPDATE &&
$entity === self::ENTITY_CUSTOMER) {
$this->cacheTypeList->cleanType(self::CACHE_TYPE_GRAPHQL_QUERY_RESOLVER_RESULT);
}
$this->cacheCleaner->flush();
return $result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Magento\ImportExport\Test\Unit\Plugin;

use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Indexer\DeferredCacheCleanerInterface;
use Magento\ImportExport\Model\Import;
use Magento\ImportExport\Plugin\DeferCacheCleaningUntilImportIsComplete;
Expand All @@ -25,14 +27,30 @@ class DeferCacheCleaningUntilImportIsCompleteTest extends TestCase
*/
private $cacheCleaner;

/**
* @var TypeListInterface|MockObject
*/
private $cacheTypeList;

/**
* @var RequestInterface|MockObject
*/
private $request;

/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->cacheCleaner = $this->getMockForAbstractClass(DeferredCacheCleanerInterface::class);
$this->plugin = new DeferCacheCleaningUntilImportIsComplete($this->cacheCleaner);
$this->cacheTypeList = $this->getMockForAbstractClass(TypeListInterface::class);
$this->request = $this->createMock(RequestInterface::class);
$this->plugin = new DeferCacheCleaningUntilImportIsComplete(
$this->cacheCleaner,
$this->cacheTypeList,
$this->request
);
}

/**
Expand All @@ -52,6 +70,11 @@ public function testAfterMethod()
{
$this->cacheCleaner->expects($this->once())->method('flush');
$subject = $this->createMock(Import::class);
// Assuming 'behavior' and 'entity' are the parameter names
$this->request->expects($this->any())->method('getParam')->willReturnMap([
['behavior', null, 'add_update'],
['entity', null, 'customer'],
]);
$result = $this->plugin->afterImportSource($subject, true);
$this->assertTrue($result);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/ProductAlert/etc/crontab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="default">
<job name="catalog_product_alert" instance="Magento\ProductAlert\Model\Observer" method="process">
<job name="product_alert" instance="Magento\ProductAlert\Model\Observer" method="process">
<config_path>crontab/default/jobs/catalog_product_alert/schedule/cron_expr</config_path>
</job>
</group>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/SalesRule/Model/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ public function processShippingAmount(Address $address)
$address->setBaseShippingDiscountAmount($this->priceCurrency->roundPrice($baseDiscountAmount));
$appliedRuleIds[$rule->getRuleId()] = $rule->getRuleId();

$this->rulesApplier->maintainAddressCouponCode($address, $rule, $this->getCouponCode());
$this->rulesApplier->addDiscountDescription(
$address,
$rule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void
* model (deprecated)
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testSaveBySetQuantityAndStockStatus()
{
Expand All @@ -61,7 +61,7 @@ public function testSaveBySetQuantityAndStockStatus()
* via product model (deprecated)
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testSaveBySetData()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void
* model (deprecated)
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testSaveBySetStockData()
{
Expand All @@ -61,7 +61,7 @@ public function testSaveBySetStockData()
* via product model (deprecated)
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testSaveBySetData()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testSave()
* product model (deprecated)
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testSaveManuallyCreatedStockItem()
{
Expand All @@ -97,7 +97,7 @@ public function testSaveManuallyCreatedStockItem()
* product repository (deprecated)
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testSaveManuallyUpdatedStockItem()
{
Expand All @@ -116,7 +116,7 @@ public function testSaveManuallyUpdatedStockItem()

/**
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testAutomaticIsInStockUpdate(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function setUp(): void
* repository
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testSaveBySetQuantityAndStockStatus()
{
Expand All @@ -61,7 +61,7 @@ public function testSaveBySetQuantityAndStockStatus()
* via product repository
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDbIsolation disabled
* @magentoDbIsolation enabled
*/
public function testSaveBySetData()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testDispatchScheduled()
\Magento\Cron\Model\ResourceModel\Schedule\Collection::class
);
$collection->addFieldToFilter('status', \Magento\Cron\Model\Schedule::STATUS_PENDING);
$collection->addFieldToFilter('job_code', 'catalog_product_alert');
$collection->addFieldToFilter('job_code', 'product_alert');
$this->assertGreaterThan(0, $collection->count(), 'Cron has failed to schedule tasks for itself for future.');
}

Expand Down
Loading

0 comments on commit 0574ac2

Please sign in to comment.