Skip to content

Commit 0b00940

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into MAGETWO-91164
2 parents 444ae24 + 73b48b4 commit 0b00940

File tree

48 files changed

+442
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+442
-101
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ language: php
1515
php:
1616
- 7.0
1717
- 7.1
18+
git:
19+
depth: 5
1820
env:
1921
global:
2022
- COMPOSER_BIN_DIR=~/bin

app/code/Magento/Backend/Block/Template.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
* Example:
1818
* <block name="my.block" class="Magento\Backend\Block\Template" template="My_Module::template.phtml" >
1919
* <arguments>
20-
* <argument name="viewModel" xsi:type="object">My\Module\ViewModel\Custom</argument>
20+
* <argument name="view_model" xsi:type="object">My\Module\ViewModel\Custom</argument>
2121
* </arguments>
2222
* </block>
2323
*
24+
* Your class object can then be accessed by doing $block->getViewModel()
25+
*
2426
* @api
2527
* @SuppressWarnings(PHPMD.NumberOfChildren)
2628
* @since 100.0.2

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Massaction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function render(\Magento\Framework\DataObject $row)
6565
*/
6666
protected function _getCheckboxHtml($value, $checked)
6767
{
68-
$id = 'id_' . rand(0, 999);
68+
$id = 'id_' . random_int(0, 999);
6969
$html = '<label class="data-grid-checkbox-cell-inner" for="'. $id .'">';
7070
$html .= '<input type="checkbox" name="' . $this->getColumn()->getName() . '" ';
7171
$html .= 'id="' . $id . '" data-role="select-row"';

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper/AttributeFilter.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,25 @@ class AttributeFilter
2828
public function prepareProductAttributes(Product $product, array $productData, array $useDefaults)
2929
{
3030
foreach ($productData as $attribute => $value) {
31-
$considerUseDefaultsAttribute = !isset($useDefaults[$attribute]) || $useDefaults[$attribute] === "1";
32-
if ($value === '' && $considerUseDefaultsAttribute) {
33-
/** @var $product Product */
34-
if ((bool)$product->getData($attribute) === (bool)$value) {
35-
unset($productData[$attribute]);
36-
}
31+
if ($this->isAttributeShouldNotBeUpdated($product, $useDefaults, $attribute, $value)) {
32+
unset($productData[$attribute]);
3733
}
3834
}
35+
3936
return $productData;
4037
}
38+
39+
/**
40+
* @param Product $product
41+
* @param $useDefaults
42+
* @param $attribute
43+
* @param $value
44+
* @return bool
45+
*/
46+
private function isAttributeShouldNotBeUpdated(Product $product, $useDefaults, $attribute, $value)
47+
{
48+
$considerUseDefaultsAttribute = !isset($useDefaults[$attribute]) || $useDefaults[$attribute] === "1";
49+
50+
return ($value === '' && $considerUseDefaultsAttribute && !$product->getData($attribute));
51+
}
4152
}

app/code/Magento/Catalog/Model/Indexer/Category/Product/AbstractAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ protected function getTemporaryTreeIndexTableName()
594594
if (empty($this->tempTreeIndexTableName)) {
595595
$this->tempTreeIndexTableName = $this->connection->getTableName('temp_catalog_category_tree_index')
596596
. '_'
597-
. substr(md5(time() . rand(0, 999999999)), 0, 8);
597+
. substr(md5(time() . random_int(0, 999999999)), 0, 8);
598598
}
599599

600600
return $this->tempTreeIndexTableName;

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ private function getTierPriceStructure($tierPricePath)
500500
'validation' => [
501501
'required-entry' => true,
502502
'validate-greater-than-zero' => true,
503-
'validate-digits' => true,
503+
'validate-digits' => false,
504+
'validate-number' => true,
504505
],
505506
],
506507
],

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function customizeAdvancedPriceFormat(array $data)
106106
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] =
107107
$this->formatPrice($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
108108
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] =
109-
(int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
109+
(float) $value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
110110
}
111111
}
112112

app/code/Magento/Catalog/view/frontend/templates/product/view/gallery.phtml

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,11 @@
4747
"data": <?= /* @escapeNotVerified */ $block->getGalleryImagesJson() ?>,
4848
"options": {
4949
"nav": "<?= /* @escapeNotVerified */ $block->getVar("gallery/nav") ?>",
50-
<?php if (($block->getVar("gallery/loop"))): ?>
51-
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/loop") ?>,
52-
<?php endif; ?>
53-
<?php if (($block->getVar("gallery/keyboard"))): ?>
54-
"keyboard": <?= /* @escapeNotVerified */ $block->getVar("gallery/keyboard") ?>,
55-
<?php endif; ?>
56-
<?php if (($block->getVar("gallery/arrows"))): ?>
57-
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/arrows") ?>,
58-
<?php endif; ?>
59-
<?php if (($block->getVar("gallery/allowfullscreen"))): ?>
60-
"allowfullscreen": <?= /* @escapeNotVerified */ $block->getVar("gallery/allowfullscreen") ?>,
61-
<?php endif; ?>
62-
<?php if (($block->getVar("gallery/caption"))): ?>
63-
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/caption") ?>,
64-
<?php endif; ?>
50+
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/loop") ? 'true' : 'false' ?>,
51+
"keyboard": <?= /* @escapeNotVerified */ $block->getVar("gallery/keyboard") ? 'true' : 'false' ?>,
52+
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/arrows") ? 'true' : 'false' ?>,
53+
"allowfullscreen": <?= /* @escapeNotVerified */ $block->getVar("gallery/allowfullscreen") ? 'true' : 'false' ?>,
54+
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/caption") ? 'true' : 'false' ?>,
6555
"width": "<?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_medium', 'width') ?>",
6656
"thumbwidth": "<?= /* @escapeNotVerified */ $block->getImageAttribute('product_page_image_small', 'width') ?>",
6757
<?php if ($block->getImageAttribute('product_page_image_small', 'height') || $block->getImageAttribute('product_page_image_small', 'width')): ?>
@@ -79,28 +69,18 @@
7969
"transitionduration": <?= /* @escapeNotVerified */ $block->getVar("gallery/transition/duration") ?>,
8070
<?php endif; ?>
8171
"transition": "<?= /* @escapeNotVerified */ $block->getVar("gallery/transition/effect") ?>",
82-
<?php if (($block->getVar("gallery/navarrows"))): ?>
83-
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/navarrows") ?>,
84-
<?php endif; ?>
72+
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/navarrows") ? 'true' : 'false' ?>,
8573
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navtype") ?>",
8674
"navdir": "<?= /* @escapeNotVerified */ $block->getVar("gallery/navdir") ?>"
8775
},
8876
"fullscreen": {
8977
"nav": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/nav") ?>",
90-
<?php if ($block->getVar("gallery/fullscreen/loop")): ?>
91-
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/loop") ?>,
92-
<?php endif; ?>
78+
"loop": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/loop") ? 'true' : 'false' ?>,
9379
"navdir": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navdir") ?>",
94-
<?php if ($block->getVar("gallery/transition/navarrows")): ?>
95-
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navarrows") ?>,
96-
<?php endif; ?>
80+
"navarrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navarrows") ? 'true' : 'false' ?>,
9781
"navtype": "<?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/navtype") ?>",
98-
<?php if ($block->getVar("gallery/fullscreen/arrows")): ?>
99-
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/arrows") ?>,
100-
<?php endif; ?>
101-
<?php if ($block->getVar("gallery/fullscreen/caption")): ?>
102-
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/caption") ?>,
103-
<?php endif; ?>
82+
"arrows": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/arrows") ? 'true' : 'false' ?>,
83+
"showCaption": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/caption") ? 'true' : 'false' ?>,
10484
<?php if ($block->getVar("gallery/fullscreen/transition/duration")): ?>
10585
"transitionduration": <?= /* @escapeNotVerified */ $block->getVar("gallery/fullscreen/transition/duration") ?>,
10686
<?php endif; ?>

app/code/Magento/CatalogInventory/Model/Stock/Item.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ public function getQtyIncrements()
401401
if ($this->getUseConfigQtyIncrements()) {
402402
$this->qtyIncrements = $this->stockConfiguration->getQtyIncrements($this->getStoreId());
403403
} else {
404-
$this->qtyIncrements = (int) $this->getData(static::QTY_INCREMENTS);
404+
$qtyIncrements = $this->getData(static::QTY_INCREMENTS);
405+
$this->qtyIncrements = $this->getIsQtyDecimal() ? (float) $qtyIncrements : (int) $qtyIncrements;
405406
}
406407
}
407408
if ($this->qtyIncrements <= 0) {

app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\CatalogInventory\Api\Data\StockItemInterface;
1111
use Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory;
1212
use Magento\CatalogInventory\Api\StockConfigurationInterface;
13-
use Magento\CatalogInventory\Api\StockItemRepositoryInterface as StockItemRepositoryInterface;
13+
use Magento\CatalogInventory\Api\StockItemRepositoryInterface;
1414
use Magento\CatalogInventory\Model\Indexer\Stock\Processor;
1515
use Magento\CatalogInventory\Model\ResourceModel\Stock\Item as StockItemResource;
1616
use Magento\CatalogInventory\Model\Spi\StockStateProviderInterface;

app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ public function testGetQtyIncrements($config, $expected)
394394
$this->setDataArrayValue('qty_increments', $config['qty_increments']);
395395
$this->setDataArrayValue('enable_qty_increments', $config['enable_qty_increments']);
396396
$this->setDataArrayValue('use_config_qty_increments', $config['use_config_qty_increments']);
397+
$this->setDataArrayValue('is_qty_decimal', $config['is_qty_decimal']);
397398
if ($config['use_config_qty_increments']) {
398399
$this->stockConfiguration->expects($this->once())
399400
->method('getQtyIncrements')
@@ -415,26 +416,38 @@ public function getQtyIncrementsDataProvider()
415416
[
416417
'qty_increments' => 1,
417418
'enable_qty_increments' => true,
418-
'use_config_qty_increments' => true
419+
'use_config_qty_increments' => true,
420+
'is_qty_decimal' => false
419421
],
420422
1
421423
],
422424
[
423425
[
424426
'qty_increments' => -2,
425427
'enable_qty_increments' => true,
426-
'use_config_qty_increments' => true
428+
'use_config_qty_increments' => true,
429+
'is_qty_decimal' => false
427430
],
428431
false
429432
],
430433
[
431434
[
432435
'qty_increments' => 3,
433436
'enable_qty_increments' => true,
434-
'use_config_qty_increments' => false
437+
'use_config_qty_increments' => false,
438+
'is_qty_decimal' => false
435439
],
436440
3
437441
],
442+
[
443+
[
444+
'qty_increments' => 0.5,
445+
'enable_qty_increments' => true,
446+
'use_config_qty_increments' => false,
447+
'is_qty_decimal' => true
448+
],
449+
0.5
450+
],
438451
];
439452
}
440453

app/code/Magento/CatalogInventory/view/adminhtml/web/js/components/qty-validator-changer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ define([
2020
var isDigits = value !== 1;
2121

2222
this.validation['validate-integer'] = isDigits;
23+
this.validation['validate-digits'] = isDigits;
2324
this.validation['less-than-equals-to'] = isDigits ? 99999999 : 99999999.9999;
2425
this.validate();
2526
}

app/code/Magento/CatalogSearch/Block/Advanced/Form.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ public function getCurrency($attribute)
201201
public function getAttributeInputType($attribute)
202202
{
203203
$dataType = $attribute->getBackend()->getType();
204-
$imputType = $attribute->getFrontend()->getInputType();
205-
if ($imputType == 'select' || $imputType == 'multiselect') {
204+
$inputType = $attribute->getFrontend()->getInputType();
205+
if ($inputType == 'select' || $inputType == 'multiselect') {
206206
return 'select';
207207
}
208208

209-
if ($imputType == 'boolean') {
209+
if ($inputType == 'boolean') {
210210
return 'yesno';
211211
}
212212

213-
if ($imputType == 'price') {
213+
if ($inputType == 'price') {
214214
return 'price';
215215
}
216216

app/code/Magento/Payment/Helper/Data.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit
293293
foreach ($methods as $code => $title) {
294294
if (isset($groups[$code])) {
295295
$labelValues[$code]['label'] = $title;
296-
$labelValues[$code]['value'] = null;
296+
if (!isset($labelValues[$code]['value'])) {
297+
$labelValues[$code]['value'] = null;
298+
}
297299
} elseif (isset($groupRelations[$code])) {
298300
unset($labelValues[$code]);
299301
$labelValues[$groupRelations[$code]]['value'][$code] = ['value' => $code, 'label' => $title];

app/code/Magento/Persistent/Observer/CheckExpirePersistentQuoteObserver.php

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
8+
declare(strict_types=1);
9+
710
namespace Magento\Persistent\Observer;
811

912
use Magento\Framework\Event\ObserverInterface;
@@ -50,28 +53,45 @@ class CheckExpirePersistentQuoteObserver implements ObserverInterface
5053
*/
5154
protected $_persistentData = null;
5255

56+
/**
57+
* Request
58+
*
59+
* @var \Magento\Framework\App\RequestInterface
60+
*/
61+
private $request;
62+
63+
/**
64+
* Checkout Page path
65+
*
66+
* @var string
67+
*/
68+
private $checkoutPagePath = 'checkout';
69+
5370
/**
5471
* @param \Magento\Persistent\Helper\Session $persistentSession
5572
* @param \Magento\Persistent\Helper\Data $persistentData
5673
* @param \Magento\Persistent\Model\QuoteManager $quoteManager
5774
* @param \Magento\Framework\Event\ManagerInterface $eventManager
5875
* @param \Magento\Customer\Model\Session $customerSession
5976
* @param \Magento\Checkout\Model\Session $checkoutSession
77+
* @param \Magento\Framework\App\RequestInterface $request
6078
*/
6179
public function __construct(
6280
\Magento\Persistent\Helper\Session $persistentSession,
6381
\Magento\Persistent\Helper\Data $persistentData,
6482
\Magento\Persistent\Model\QuoteManager $quoteManager,
6583
\Magento\Framework\Event\ManagerInterface $eventManager,
6684
\Magento\Customer\Model\Session $customerSession,
67-
\Magento\Checkout\Model\Session $checkoutSession
85+
\Magento\Checkout\Model\Session $checkoutSession,
86+
\Magento\Framework\App\RequestInterface $request
6887
) {
6988
$this->_persistentSession = $persistentSession;
7089
$this->quoteManager = $quoteManager;
7190
$this->_customerSession = $customerSession;
7291
$this->_checkoutSession = $checkoutSession;
7392
$this->_eventManager = $eventManager;
7493
$this->_persistentData = $persistentData;
94+
$this->request = $request;
7595
}
7696

7797
/**
@@ -90,12 +110,32 @@ public function execute(\Magento\Framework\Event\Observer $observer)
90110
!$this->_persistentSession->isPersistent() &&
91111
!$this->_customerSession->isLoggedIn() &&
92112
$this->_checkoutSession->getQuoteId() &&
93-
!$observer->getControllerAction() instanceof \Magento\Checkout\Controller\Onepage
94-
// persistent session does not expire on onepage checkout page to not spoil customer group id
113+
!$this->isRequestFromCheckoutPage($this->request)
114+
// persistent session does not expire on onepage checkout page
95115
) {
96116
$this->_eventManager->dispatch('persistent_session_expired');
97117
$this->quoteManager->expire();
98118
$this->_customerSession->setCustomerId(null)->setCustomerGroupId(null);
99119
}
100120
}
121+
122+
/**
123+
* Check current request is coming from onepage checkout page.
124+
*
125+
* @param \Magento\Framework\App\RequestInterface $request
126+
* @return bool
127+
*/
128+
private function isRequestFromCheckoutPage(\Magento\Framework\App\RequestInterface $request): bool
129+
{
130+
$requestUri = (string)$request->getRequestUri();
131+
$refererUri = (string)$request->getServer('HTTP_REFERER');
132+
133+
/** @var bool $isCheckoutPage */
134+
$isCheckoutPage = (
135+
false !== strpos($requestUri, $this->checkoutPagePath) ||
136+
false !== strpos($refererUri, $this->checkoutPagePath)
137+
);
138+
139+
return $isCheckoutPage;
140+
}
101141
}

0 commit comments

Comments
 (0)