Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Public Pull Requests:
 - #14183: [Forwardport] Fix product attribute ordering when more than 10 attributes (by @rostyslav-hymon)
 - #14179: [Forwardport] Fix for Issue-13556 - Sorting in Product Listing via Quantity not work (by @dimonovp)
 - #14182: [Forwardport] Fix faulty admin spinner animation (by @dimonovp)
 - #14180: [Forwardport] Act better on existing input focus instead of removing it (by @mastiuhin-olexandr)
 - #14178: [Forwardport] Minicart should require dropdownDialog (by @rostyslav-hymon)
 - #14177: [Forwardport] Default Welcome message is broken on storefront with enabled translate-inline (by @dimonovp)
 - #14174: [Forwardport] Solved this issue : Drop down values are not showing in catalog produ� (by @dimonovp)
 - #14165: [Forwardport 2.3] Added mage/translate component to customers's ajax login (by @ccasciotti)
 - #13885: #5463 - Use specified hashing algo in \Magento\Framework\Encryption\Encryptor::getHash (by @k4emic)
 - #14158: Improve Customer GraphQL Model code quality (by @elzekool)


Fixed GitHub Issues:
 - #13556: Sorting in Product Listing via Quantity not work (reported by @LordHansolo) has been fixed in #14179 by @dimonovp in 2.3-develop branch
   Related commits:
     1. ce6dd85
     2. a6dc79a
     3. bcb553c
     4. 551fa25

 - #13988: Mini search field looses focus after its JavaScript is initialized (reported by @krzksz) has been fixed in #14180 by @mastiuhin-olexandr in 2.3-develop branch
   Related commits:
     1. 2f624a4

 - #12711: Default Welcome message is broken on storefront with enabled translate-inline (reported by @alena-marchenko) has been fixed in #14177 by @dimonovp in 2.3-develop branch
   Related commits:
     1. 4147b53
     2. 0610449
     3. 5367c47

 - #13006: Drop down values are not showing in catalog product grid magento2 (reported by @ramusadwika) has been fixed in #14174 by @dimonovp in 2.3-develop branch
   Related commits:
     1. 80887ac

 - #5463: The ability to store passwords using different hashing algorithms is limited (reported by @maderlock) has been fixed in #13885 by @k4emic in 2.3-develop branch
   Related commits:
     1. d537d56
  • Loading branch information
magento-engcom-team committed Mar 20, 2018
2 parents 620d37d + 43e65fa commit 447a24d
Show file tree
Hide file tree
Showing 14 changed files with 114 additions and 16 deletions.
19 changes: 19 additions & 0 deletions app/code/Magento/CatalogInventory/Model/Source/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,23 @@ public function getAllOptions()
['value' => \Magento\CatalogInventory\Model\Stock::STOCK_OUT_OF_STOCK, 'label' => __('Out of Stock')]
];
}

/**
* Add Value Sort To Collection Select.
*
* @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
* @param string $dir
*
* @return $this
*/
public function addValueSortToCollection($collection, $dir = \Magento\Framework\Data\Collection::SORT_ORDER_DESC)
{
$collection->getSelect()->joinLeft(
['stock_item_table' => 'cataloginventory_stock_item'],
"e.entity_id=stock_item_table.product_id",
[]
);
$collection->getSelect()->order("stock_item_table.qty $dir");
return $this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\CatalogInventory\Test\Unit\Model\Source;

use PHPUnit\Framework\TestCase;

class StockTest extends TestCase
{
/**
* @var \Magento\CatalogInventory\Model\Source\Stock
*/
private $model;

protected function setUp()
{
$this->model = new \Magento\CatalogInventory\Model\Source\Stock();
}

public function testAddValueSortToCollection()
{
$selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
$collectionMock = $this->createMock(\Magento\Eav\Model\Entity\Collection\AbstractCollection::class);
$collectionMock->expects($this->atLeastOnce())->method('getSelect')->willReturn($selectMock);

$selectMock->expects($this->once())
->method('joinLeft')
->with(
['stock_item_table' => 'cataloginventory_stock_item'],
"e.entity_id=stock_item_table.product_id",
[]
)
->willReturnSelf();
$selectMock->expects($this->once())
->method('order')
->with("stock_item_table.qty DESC")
->willReturnSelf();

$this->model->addValueSortToCollection($collectionMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ define([
'ko',
'underscore',
'sidebar',
'mage/translate'
'mage/translate',
'mage/dropdown'
], function (Component, customerData, $, ko, _) {
'use strict';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ define([
'jquery',
'mage/storage',
'Magento_Ui/js/model/messageList',
'Magento_Customer/js/customer-data'
], function ($, storage, globalMessageList, customerData) {
'Magento_Customer/js/customer-data',
'mage/translate'
], function ($, storage, globalMessageList, customerData, $t) {
'use strict';

var callbacks = [],
Expand Down Expand Up @@ -48,7 +49,7 @@ define([
}
}).fail(function () {
messageContainer.addErrorMessage({
'message': 'Could not authenticate. Please try again later'
'message': $t('Could not authenticate. Please try again later')
});
callbacks.forEach(function (callback) {
callback(loginData);
Expand Down
9 changes: 5 additions & 4 deletions app/code/Magento/CustomerGraphQl/Model/Resolver/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

namespace Magento\CustomerGraphQl\Model\Resolver;

use Magento\Authorization\Model\UserContextInterface;
use Magento\CustomerGraphQl\Model\Resolver\Customer\CustomerDataProvider;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\GraphQl\Model\ResolverInterface;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\GraphQl\Model\ResolverContextInterface;

/**
Expand All @@ -24,10 +25,10 @@ class Customer implements ResolverInterface
private $customerResolver;

/**
* @param \Magento\CustomerGraphQl\Model\Resolver\Customer\CustomerDataProvider $customerResolver
* @param CustomerDataProvider $customerResolver
*/
public function __construct(
\Magento\CustomerGraphQl\Model\Resolver\Customer\CustomerDataProvider $customerResolver
CustomerDataProvider $customerResolver
) {
$this->customerResolver = $customerResolver;
}
Expand All @@ -37,7 +38,7 @@ public function __construct(
*/
public function resolve(array $args, ResolverContextInterface $context)
{
if ((!$context->getUserId()) || $context->getUserType() == 4) {
if ((!$context->getUserId()) || $context->getUserType() == UserContextInterface::USER_TYPE_GUEST) {
throw new GraphQlAuthorizationException(
__(
'Current customer does not have access to the resource "%1"',
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/CustomerGraphQl/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"require": {
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0",
"magento/module-customer": "100.2.*",
"magento/module-authorization": "100.3.*",
"magento/module-graph-ql": "100.0.*",
"magento/framework": "100.3.*"
},
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/CustomerGraphQl/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<module name="Magento_CustomerGraphQl" >
<sequence>
<module name="Magento_Customer"/>
<module name="Magento_Authorization"/>
<module name="Magento_GraphQl"/>
</sequence>
</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function addOptionValueToCollection($collection, $attribute, $valueExpr)
);
$valueExpr = $connection->getCheckSql(
"{$optionTable2}.value_id IS NULL",
"{$optionTable1}.value",
"{$optionTable2}.value"
"{$optionTable1}.option_id",
"{$optionTable2}.option_id"
);

$collection->getSelect()->joinLeft(
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Search/view/frontend/web/form-mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ define([
}, this), 250);
}, this));

this.element.trigger('blur');
if (this.element.get(0) === document.activeElement) {
this.setActiveState(true);
}

this.element.on('focus', this.setActiveState.bind(this, true));
this.element.on('keydown', this._onKeyDown);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ define([
*/
_sortAttributes: function () {
this.options.jsonConfig.attributes = _.sortBy(this.options.jsonConfig.attributes, function (attribute) {
return attribute.position;
return parseInt(attribute.position, 10);
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $welcomeMessage = $block->getWelcome();
</span>
<!-- /ko -->
<!-- ko ifnot: customer().fullname -->
<span data-bind='html:"<?= $block->escapeHtmlAttr($welcomeMessage) ?>"'></span>
<span data-bind='html:"<?= $block->escapeHtml($welcomeMessage) ?>"'></span>
<?= $block->getBlockHtml('header.additional') ?>
<!-- /ko -->
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
@spinner-rotate-step: 45;

// One step in degree
@spinner-delay: .9;
@spinner-delay: .9s;
4 changes: 2 additions & 2 deletions lib/internal/Magento/Framework/Encryption/Encryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function validateCipher($version)
public function getHash($password, $salt = false, $version = self::HASH_VERSION_LATEST)
{
if ($salt === false) {
return $this->hash($password);
return $this->hash($password, $version);
}
if ($salt === true) {
$salt = self::DEFAULT_SALT_LENGTH;
Expand All @@ -160,7 +160,7 @@ public function getHash($password, $salt = false, $version = self::HASH_VERSION_
return implode(
self::DELIMITER,
[
$this->hash($salt . $password),
$this->hash($salt . $password, $version),
$salt,
$version
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,32 @@ public function testValidateKey()
$this->assertEquals($expectedEncryptedData, $actualEncryptedData);
$this->assertEquals($crypt->decrypt($expectedEncryptedData), $actual->decrypt($actualEncryptedData));
}

public function testUseSpecifiedHashingAlgoDataProvider()
{
return [
['password', 'salt', Encryptor::HASH_VERSION_MD5,
'67a1e09bb1f83f5007dc119c14d663aa:salt:0'],
['password', 'salt', Encryptor::HASH_VERSION_SHA256,
'13601bda4ea78e55a07b98866d2be6be0744e3866f13c00c811cab608a28f322:salt:1'],
['password', false, Encryptor::HASH_VERSION_MD5,
'5f4dcc3b5aa765d61d8327deb882cf99'],
['password', false, Encryptor::HASH_VERSION_SHA256,
'5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8']
];
}

/**
* @dataProvider testUseSpecifiedHashingAlgoDataProvider
*
* @param $password
* @param $salt
* @param $hashAlgo
* @param $expected
*/
public function testGetHashMustUseSpecifiedHashingAlgo($password, $salt, $hashAlgo, $expected)
{
$hash = $this->_model->getHash($password, $salt, $hashAlgo);
$this->assertEquals($expected, $hash);
}
}

0 comments on commit 447a24d

Please sign in to comment.