Skip to content

Commit

Permalink
Merge branch '2.4-develop' into some-changes-in-mftf
Browse files Browse the repository at this point in the history
  • Loading branch information
engcom-Charlie committed Aug 6, 2020
2 parents 45a3a77 + 5daadae commit 91a6a68
Show file tree
Hide file tree
Showing 547 changed files with 27,286 additions and 594 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For more detailed information on contribution please read our [beginners guide](
* Unit/integration test coverage
* Proposed [documentation](https://devdocs.magento.com) updates. Documentation contributions can be submitted via the [devdocs GitHub](https://github.com/magento/devdocs).
4. For larger features or changes, please [open an issue](https://github.com/magento/magento2/issues) to discuss the proposed changes prior to development. This may prevent duplicate or unnecessary effort and allow other contributors to provide input.
5. All automated tests must pass (all builds on [Travis CI](https://travis-ci.org/magento/magento2) must be green).
5. All automated tests must pass.

## Contribution process

Expand Down
9 changes: 0 additions & 9 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,6 @@
Require all denied
</IfVersion>
</Files>
<Files .travis.yml>
<IfVersion < 2.4>
order allow,deny
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
</Files>
<Files CHANGELOG.md>
<IfVersion < 2.4>
order allow,deny
Expand Down
9 changes: 0 additions & 9 deletions .htaccess.sample
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,6 @@
Require all denied
</IfVersion>
</Files>
<Files .travis.yml>
<IfVersion < 2.4>
order allow,deny
deny from all
</IfVersion>
<IfVersion >= 2.4>
Require all denied
</IfVersion>
</Files>
<Files CHANGELOG.md>
<IfVersion < 2.4>
order allow,deny
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@ public function build(array $args, bool $includeAggregation): SearchCriteriaInte
}

if (!$searchCriteria->getSortOrders()) {
$this->addDefaultSortOrder($searchCriteria, $isSearch);
$this->addDefaultSortOrder($searchCriteria, $args, $isSearch);
}

$this->addEntityIdSort($searchCriteria, $isSearch);
$this->addVisibilityFilter($searchCriteria, $isSearch, !empty($args['filter']));

$searchCriteria->setCurrentPage($args['currentPage']);
Expand Down Expand Up @@ -132,6 +133,25 @@ private function addVisibilityFilter(SearchCriteriaInterface $searchCriteria, bo
$this->addFilter($searchCriteria, 'visibility', $visibilityIds, 'in');
}

/**
* Add sort by Entity ID
*
* @param SearchCriteriaInterface $searchCriteria
* @param bool $isSearch
*/
private function addEntityIdSort(SearchCriteriaInterface $searchCriteria, bool $isSearch): void
{
if ($isSearch) {
return;
}
$sortOrderArray = $searchCriteria->getSortOrders();
$sortOrderArray[] = $this->sortOrderBuilder
->setField('_id')
->setDirection(SortOrder::SORT_DESC)
->create();
$searchCriteria->setSortOrders($sortOrderArray);
}

/**
* Prepare price aggregation algorithm
*
Expand Down Expand Up @@ -179,18 +199,32 @@ private function addFilter(
* Sort by relevance DESC by default
*
* @param SearchCriteriaInterface $searchCriteria
* @param array $args
* @param bool $isSearch
*/
private function addDefaultSortOrder(SearchCriteriaInterface $searchCriteria, $isSearch = false): void
private function addDefaultSortOrder(SearchCriteriaInterface $searchCriteria, array $args, $isSearch = false): void
{
$sortField = $isSearch ? 'relevance' : EavAttributeInterface::POSITION;
$sortDirection = $isSearch ? SortOrder::SORT_DESC : SortOrder::SORT_ASC;
$defaultSortOrder = $this->sortOrderBuilder
->setField($sortField)
->setDirection($sortDirection)
->create();
$defaultSortOrder = [];
if ($isSearch) {
$defaultSortOrder[] = $this->sortOrderBuilder
->setField('relevance')
->setDirection(SortOrder::SORT_DESC)
->create();
} else {
$categoryIdFilter = isset($args['filter']['category_id']) ? $args['filter']['category_id'] : false;
if ($categoryIdFilter) {
if (!is_array($categoryIdFilter[array_key_first($categoryIdFilter)])
|| count($categoryIdFilter[array_key_first($categoryIdFilter)]) <= 1
) {
$defaultSortOrder[] = $this->sortOrderBuilder
->setField(EavAttributeInterface::POSITION)
->setDirection(SortOrder::SORT_ASC)
->create();
}
}
}

$searchCriteria->setSortOrders([$defaultSortOrder]);
$searchCriteria->setSortOrders($defaultSortOrder);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Framework\Exception\InputException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\Resolver\Argument\SearchCriteria\ArgumentApplier\Filter;
use Magento\Framework\GraphQl\Query\Resolver\Argument\SearchCriteria\ArgumentApplier\Sort;
use Magento\Search\Model\Query;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\ScopeInterface;
Expand Down Expand Up @@ -71,6 +72,7 @@ public function getResult(array $criteria, StoreInterface $store)
$categoryIds = [];
$criteria[Filter::ARGUMENT_NAME] = $this->formatMatchFilters($criteria['filters'], $store);
$criteria[Filter::ARGUMENT_NAME][CategoryInterface::KEY_IS_ACTIVE] = ['eq' => 1];
$criteria[Sort::ARGUMENT_NAME][CategoryInterface::KEY_POSITION] = ['ASC'];
$searchCriteria = $this->searchCriteriaBuilder->build('categoryList', $criteria);
$pageSize = $criteria['pageSize'] ?? 20;
$currentPage = $criteria['currentPage'] ?? 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ private function getSortOrderArray(SearchCriteriaInterface $searchCriteria)
$sortOrders = $searchCriteria->getSortOrders();
if (is_array($sortOrders)) {
foreach ($sortOrders as $sortOrder) {
// I am replacing _id with entity_id because in ElasticSearch _id is required for sorting by ID.
// Where as entity_id is required when using ID as the sort in $collection->load();.
// @see \Magento\CatalogGraphQl\Model\Resolver\Products\Query\Search::getResult
if ($sortOrder->getField() === '_id') {
$sortOrder->setField('entity_id');
}
$ordersArray[$sortOrder->getField()] = $sortOrder->getDirection();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Magento\CatalogGraphQl\Model\Resolver\Products\SearchResult;
use Magento\CatalogGraphQl\Model\Resolver\Products\SearchResultFactory;
use Magento\Framework\Api\Search\SearchCriteriaInterface;
use Magento\Framework\Exception\InputException;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\GraphQl\Model\Query\ContextInterface;
use Magento\Search\Api\SearchInterface;
Expand Down Expand Up @@ -83,6 +84,7 @@ public function __construct(
* @param ResolveInfo $info
* @param ContextInterface $context
* @return SearchResult
* @throws InputException
*/
public function getResult(
array $args,
Expand All @@ -103,7 +105,12 @@ public function getResult(
//Address limitations of sort and pagination on search API apply original pagination from GQL query
$searchCriteria->setPageSize($realPageSize);
$searchCriteria->setCurrentPage($realCurrentPage);
$searchResults = $this->productsProvider->getList($searchCriteria, $itemsResults, $queryFields, $context);
$searchResults = $this->productsProvider->getList(
$searchCriteria,
$itemsResults,
$queryFields,
$context
);

$totalPages = $realPageSize ? ((int)ceil($searchResults->getTotalCount() / $realPageSize)) : 0;

Expand Down
17 changes: 13 additions & 4 deletions app/code/Magento/Checkout/view/frontend/web/js/region-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ define([
regionInput = $(this.options.regionInputId),
postcode = $(this.options.postcodeId),
label = regionList.parent().siblings('label'),
container = regionList.parents('div.field');
container = regionList.parents('div.field'),
regionsEntries,
regionId,
regionData;

this._clearError();
this._checkRegionRequired(country);
Expand All @@ -168,8 +171,14 @@ define([
// Populate state/province dropdown list if available or use input box
if (this.options.regionJson[country]) {
this._removeSelectOptions(regionList);
$.each(this.options.regionJson[country], $.proxy(function (key, value) {
this._renderSelectOption(regionList, key, value);
regionsEntries = _.pairs(this.options.regionJson[country]);
regionsEntries.sort(function (a, b) {
return a[1].name > b[1].name ? 1 : -1;
});
$.each(regionsEntries, $.proxy(function (key, value) {
regionId = value[0];
regionData = value[1];
this._renderSelectOption(regionList, regionId, regionData);
}, this));

if (this.currentRegionOption) {
Expand All @@ -193,7 +202,7 @@ define([
regionList.hide();
container.hide();
} else {
regionList.show();
regionList.removeAttr('disabled').show();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* @api
*/
define([], function () {
define(['underscore'], function (_) {
'use strict';

/**
Expand Down Expand Up @@ -44,7 +44,7 @@ define([], function () {
vatId: addressData['vat_id'],
sameAsBilling: addressData['same_as_billing'],
saveInAddressBook: addressData['save_in_address_book'],
customAttributes: addressData['custom_attributes'],
customAttributes: _.toArray(addressData['custom_attributes']).reverse(),

/**
* @return {*}
Expand Down
48 changes: 30 additions & 18 deletions app/code/Magento/Deploy/Process/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Queue
/**
* Default max execution time
*/
const DEFAULT_MAX_EXEC_TIME = 400;
const DEFAULT_MAX_EXEC_TIME = 900;

/**
* @var array
Expand Down Expand Up @@ -96,6 +96,11 @@ class Queue
*/
private $lastJobStarted = 0;

/**
* @var int
*/
private $logDelay;

/**
* @param AppState $appState
* @param LocaleResolver $localeResolver
Expand Down Expand Up @@ -157,11 +162,12 @@ public function getPackages()
* Process jobs
*
* @return int
* @throws TimeoutException
*/
public function process()
{
$returnStatus = 0;
$logDelay = 10;
$this->logDelay = 10;
$this->start = $this->lastJobStarted = time();
$packages = $this->packages;
while (count($packages) && $this->checkTimeout()) {
Expand All @@ -170,13 +176,7 @@ public function process()
$this->assertAndExecute($name, $packages, $packageJob);
}

// refresh current status in console once in 10 iterations (once in 5 sec)
if ($logDelay >= 10) {
$this->logger->info('.');
$logDelay = 0;
} else {
$logDelay++;
}
$this->refreshStatus();

if ($this->isCanBeParalleled()) {
// in parallel mode sleep before trying to check status and run new jobs
Expand All @@ -193,9 +193,28 @@ public function process()

$this->awaitForAllProcesses();

if (!empty($packages)) {
throw new TimeoutException('Not all packages are deployed.');
}

return $returnStatus;
}

/**
* Refresh current status in console once in 10 iterations (once in 5 sec)
*
* @return void
*/
private function refreshStatus(): void
{
if ($this->logDelay >= 10) {
$this->logger->info('.');
$this->logDelay = 0;
} else {
$this->logDelay++;
}
}

/**
* Check that all depended packages deployed and execute
*
Expand All @@ -204,7 +223,7 @@ public function process()
* @param array $packageJob
* @return void
*/
private function assertAndExecute($name, array & $packages, array $packageJob)
private function assertAndExecute($name, array &$packages, array $packageJob)
{
/** @var Package $package */
$package = $packageJob['package'];
Expand Down Expand Up @@ -256,21 +275,14 @@ private function executePackage(Package $package, string $name, array &$packages
*/
private function awaitForAllProcesses()
{
$logDelay = 10;
while ($this->inProgress && $this->checkTimeout()) {
foreach ($this->inProgress as $name => $package) {
if ($this->isDeployed($package)) {
unset($this->inProgress[$name]);
}
}

// refresh current status in console once in 10 iterations (once in 5 sec)
if ($logDelay >= 10) {
$this->logger->info('.');
$logDelay = 0;
} else {
$logDelay++;
}
$this->refreshStatus();

// sleep before checking parallel jobs status
// phpcs:ignore Magento2.Functions.DiscouragedFunction
Expand Down
15 changes: 15 additions & 0 deletions app/code/Magento/Deploy/Process/TimeoutException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Deploy\Process;

/**
* Exception is thrown if deploy process is finished due to timeout.
*/
class TimeoutException extends \RuntimeException
{
}

0 comments on commit 91a6a68

Please sign in to comment.