Skip to content

Commit d6499ed

Browse files
author
Ievgen Shakhsuvarov
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into bugs
2 parents 73068cc + cd08089 commit d6499ed

File tree

247 files changed

+3634
-2565
lines changed

Some content is hidden

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

247 files changed

+3634
-2565
lines changed

app/bootstrap.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@
3131
require_once __DIR__ . '/autoload.php';
3232
require_once BP . '/app/functions.php';
3333

34-
if (!empty($_SERVER['MAGE_PROFILER'])) {
35-
\Magento\Framework\Profiler::applyConfig($_SERVER['MAGE_PROFILER'], BP, !empty($_REQUEST['isAjax']));
34+
if (!empty($_SERVER['MAGE_PROFILER'])
35+
&& isset($_SERVER['HTTP_ACCEPT'])
36+
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
37+
) {
38+
\Magento\Framework\Profiler::applyConfig(
39+
$_SERVER['MAGE_PROFILER'],
40+
BP,
41+
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
42+
);
3643
}
3744
if (ini_get('date.timezone') == '') {
3845
date_default_timezone_set('UTC');

app/code/Magento/Authorizenet/Controller/Directpost/Payment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ protected function _returnCustomerQuote($cancelOrder = false, $errorMsg = '')
130130
$order = $this->_objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($incrementId);
131131
if ($order->getId()) {
132132
try {
133-
/** @var \Magento\Quote\Model\QuoteRepository $quoteRepository */
134-
$quoteRepository = $this->_objectManager->create('Magento\Quote\Model\QuoteRepository');
133+
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
134+
$quoteRepository = $this->_objectManager->create('Magento\Quote\Api\CartRepositoryInterface');
135135
/** @var \Magento\Quote\Model\Quote $quote */
136136
$quote = $quoteRepository->get($order->getQuoteId());
137137

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
9393
protected $storeManager;
9494

9595
/**
96-
* @var \Magento\Quote\Model\QuoteRepository
96+
* @var \Magento\Quote\Api\CartRepositoryInterface
9797
*/
9898
protected $quoteRepository;
9999

@@ -136,7 +136,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet implements Tra
136136
* @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
137137
* @param \Magento\Sales\Model\OrderFactory $orderFactory
138138
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
139-
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
139+
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
140140
* @param OrderSender $orderSender
141141
* @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository
142142
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
@@ -161,7 +161,7 @@ public function __construct(
161161
ZendClientFactory $httpClientFactory,
162162
\Magento\Sales\Model\OrderFactory $orderFactory,
163163
\Magento\Store\Model\StoreManagerInterface $storeManager,
164-
\Magento\Quote\Model\QuoteRepository $quoteRepository,
164+
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
165165
\Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender,
166166
\Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository,
167167
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,

app/code/Magento/Backend/Model/Session/Quote.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Quote extends \Magento\Framework\Session\SessionManager
6060
/**
6161
* Sales quote repository
6262
*
63-
* @var \Magento\Quote\Model\QuoteRepository
63+
* @var \Magento\Quote\Api\CartRepositoryInterface
6464
*/
6565
protected $quoteRepository;
6666

@@ -74,6 +74,11 @@ class Quote extends \Magento\Framework\Session\SessionManager
7474
*/
7575
protected $groupManagement;
7676

77+
/**
78+
* @var \Magento\Quote\Model\QuoteFactory
79+
*/
80+
protected $quoteFactory;
81+
7782
/**
7883
* @param \Magento\Framework\App\Request\Http $request
7984
* @param \Magento\Framework\Session\SidResolverInterface $sidResolver
@@ -85,11 +90,11 @@ class Quote extends \Magento\Framework\Session\SessionManager
8590
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
8691
* @param \Magento\Framework\App\State $appState
8792
* @param CustomerRepositoryInterface $customerRepository
88-
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
93+
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
8994
* @param \Magento\Sales\Model\OrderFactory $orderFactory
9095
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
9196
* @param GroupManagementInterface $groupManagement
92-
* @throws \Magento\Framework\Exception\SessionException
97+
* @param \Magento\Quote\Model\QuoteFactory $quoteFactory
9398
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9499
*/
95100
public function __construct(
@@ -103,16 +108,18 @@ public function __construct(
103108
\Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
104109
\Magento\Framework\App\State $appState,
105110
CustomerRepositoryInterface $customerRepository,
106-
\Magento\Quote\Model\QuoteRepository $quoteRepository,
111+
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
107112
\Magento\Sales\Model\OrderFactory $orderFactory,
108113
\Magento\Store\Model\StoreManagerInterface $storeManager,
109-
GroupManagementInterface $groupManagement
114+
GroupManagementInterface $groupManagement,
115+
\Magento\Quote\Model\QuoteFactory $quoteFactory
110116
) {
111117
$this->customerRepository = $customerRepository;
112118
$this->quoteRepository = $quoteRepository;
113119
$this->_orderFactory = $orderFactory;
114120
$this->_storeManager = $storeManager;
115121
$this->groupManagement = $groupManagement;
122+
$this->quoteFactory = $quoteFactory;
116123
parent::__construct(
117124
$request,
118125
$sidResolver,
@@ -137,7 +144,7 @@ public function __construct(
137144
public function getQuote()
138145
{
139146
if ($this->_quote === null) {
140-
$this->_quote = $this->quoteRepository->create();
147+
$this->_quote = $this->quoteFactory->create();
141148
if ($this->getStoreId()) {
142149
if (!$this->getQuoteId()) {
143150
$this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId())

app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/**
99
* Class QuoteTest
1010
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
11+
* @SuppressWarnings(PHPMD.TooManyFields)
1112
*/
1213
class QuoteTest extends \PHPUnit_Framework_TestCase
1314
{
@@ -86,6 +87,11 @@ class QuoteTest extends \PHPUnit_Framework_TestCase
8687
*/
8788
protected $groupManagementMock;
8889

90+
/**
91+
* @var \PHPUnit_Framework_MockObject_MockObject
92+
*/
93+
protected $quoteFactoryMock;
94+
8995
/**
9096
* Set up
9197
*
@@ -122,13 +128,7 @@ protected function setUp()
122128
true,
123129
['getValue']
124130
);
125-
$this->quoteRepositoryMock = $this->getMock(
126-
'Magento\Quote\Model\QuoteRepository',
127-
['create', 'save', 'get'],
128-
[],
129-
'',
130-
false
131-
);
131+
$this->quoteRepositoryMock = $this->getMock('Magento\Quote\Api\CartRepositoryInterface');
132132

133133
$this->requestMock = $this->getMock(
134134
'Magento\Framework\App\Request\Http',
@@ -196,6 +196,8 @@ protected function setUp()
196196
false
197197
);
198198

199+
$this->quoteFactoryMock = $this->getMock('\Magento\Quote\Model\QuoteFactory', ['create'], [], '', false);
200+
199201
$this->quote = $this->getMock(
200202
'Magento\Backend\Model\Session\Quote',
201203
['getStoreId', 'getQuoteId', 'setQuoteId', 'hasCustomerId', 'getCustomerId'],
@@ -214,6 +216,7 @@ protected function setUp()
214216
'orderFactory' => $this->orderFactoryMock,
215217
'storeManager' => $this->storeManagerMock,
216218
'groupManagement' => $this->groupManagementMock,
219+
'quoteFactory' => $this->quoteFactoryMock
217220
],
218221
'',
219222
true
@@ -302,7 +305,7 @@ public function testGetQuoteWithoutQuoteId()
302305
->method('setIsSuperMode')
303306
->with(true);
304307

305-
$this->quoteRepositoryMock->expects($this->once())
308+
$this->quoteFactoryMock->expects($this->once())
306309
->method('create')
307310
->will($this->returnValue($quoteMock));
308311
$this->quoteRepositoryMock->expects($this->once())
@@ -377,7 +380,7 @@ public function testGetQuoteWithQuoteId($customerId, $quoteCustomerId, $expected
377380
->method('getCustomerId')
378381
->will($this->returnValue($quoteCustomerId));
379382

380-
$this->quoteRepositoryMock->expects($this->once())
383+
$this->quoteFactoryMock->expects($this->once())
381384
->method('create')
382385
->will($this->returnValue($quoteMock));
383386
$this->quoteRepositoryMock->expects($this->once())

app/code/Magento/Braintree/Test/Unit/Model/CheckoutTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CheckoutTest extends \PHPUnit_Framework_TestCase
5757
protected $shippingAddressMock;
5858

5959
/**
60-
* @var \Magento\Quote\Model\QuoteRepository|\PHPUnit_Framework_MockObject_MockObject
60+
* @var \Magento\Quote\Api\CartRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
6161
*/
6262
protected $quoteRepositoryMock;
6363

@@ -73,10 +73,7 @@ protected function setUp()
7373
$this->quoteMock->expects($this->any())
7474
->method('getShippingAddress')
7575
->willReturn($this->shippingAddressMock);
76-
$this->quoteRepositoryMock = $this->getMockBuilder('\Magento\Quote\Model\QuoteRepository')
77-
->disableOriginalConstructor()
78-
->getMock();
79-
76+
$this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Api\CartRepositoryInterface');
8077
$configMock = $this->getMockBuilder('\Magento\Paypal\Model\Config')
8178
->disableOriginalConstructor()
8279
->getMock();

app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\CatalogImportExport\Model\Import\Product as ImportProductModel;
1111
use Magento\Bundle\Model\ResourceModel\Selection\Collection as SelectionCollection;
1212
use Magento\ImportExport\Controller\Adminhtml\Import;
13+
use Magento\ImportExport\Model\Import as ImportModel;
1314

1415
/**
1516
* Class RowCustomizer
@@ -90,20 +91,21 @@ class RowCustomizer implements RowCustomizerInterface
9091
* Prepare data for export
9192
*
9293
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
93-
* @param int $productIds
94+
* @param int[] $productIds
9495
* @return $this
9596
*/
9697
public function prepareData($collection, $productIds)
9798
{
98-
$collection->addAttributeToFilter(
99+
$productCollection = clone $collection;
100+
$productCollection->addAttributeToFilter(
99101
'entity_id',
100102
['in' => $productIds]
101103
)->addAttributeToFilter(
102104
'type_id',
103105
['eq' => \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE]
104106
);
105107

106-
return $this->populateBundleData($collection);
108+
return $this->populateBundleData($productCollection);
107109
}
108110

109111
/**
@@ -214,9 +216,9 @@ protected function getFormattedBundleSelections($optionValues, SelectionCollecti
214216
'price_type' => $this->getPriceTypeValue($selection->getSelectionPriceType())
215217
];
216218
$bundleData .= $optionValues
217-
. ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
219+
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
218220
. implode(
219-
ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
221+
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
220222
array_map(
221223
function ($value, $key) {
222224
return $key . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $value;
@@ -240,9 +242,9 @@ function ($value, $key) {
240242
protected function getFormattedOptionValues($option)
241243
{
242244
return 'name' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
243-
. $option->getTitle() . ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
245+
. $option->getTitle() . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
244246
. 'type' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
245-
. $option->getType() . ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
247+
. $option->getType() . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
246248
. 'required' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
247249
. $option->getRequired();
248250
}
@@ -290,7 +292,7 @@ protected function cleanNotBundleAdditionalAttributes($dataRow)
290292
{
291293
if (!empty($dataRow['additional_attributes'])) {
292294
$additionalAttributes = explode(
293-
ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
295+
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
294296
$dataRow['additional_attributes']
295297
);
296298
$dataRow['additional_attributes'] = $this->getNotBundleAttributes($additionalAttributes);
@@ -314,10 +316,10 @@ protected function getNotBundleAttributes($additionalAttributes)
314316
$cleanedAdditionalAttributes .= $attributeCode
315317
. ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
316318
. $attributeValue
317-
. ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
319+
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
318320
}
319321
}
320322

321-
return rtrim($cleanedAdditionalAttributes, ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
323+
return rtrim($cleanedAdditionalAttributes, ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
322324
}
323325
}

app/code/Magento/Catalog/Model/Category.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,9 +1086,10 @@ public function reindex()
10861086
$flatIndexer->reindexRow($this->getId());
10871087
}
10881088
}
1089-
$affectedProductIds = $this->getAffectedProductIds();
10901089
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
1091-
if (!$productIndexer->isScheduled() && !empty($affectedProductIds)) {
1090+
if (!$productIndexer->isScheduled()
1091+
&& (!empty($this->getAffectedProductIds()) || $this->dataHasChangedFor('is_anchor'))
1092+
) {
10921093
$productIndexer->reindexList($this->getPathIds());
10931094
}
10941095
}

app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,21 +380,37 @@ public function testReindexFlatEnabled($flatScheduled, $productScheduled, $expec
380380
public function reindexFlatDisabledTestDataProvider()
381381
{
382382
return [
383-
'set 1' => [false, 1],
384-
'set 2' => [true, 0],
383+
[false, null, null, null, 0],
384+
[true, null, null, null, 0],
385+
[false, [], null, null, 0],
386+
[false, ["1", "2"], null, null, 1],
387+
[false, null, 1, null, 1],
388+
[false, ["1", "2"], 0, 1, 1],
389+
[false, null, 1, 1, 0],
385390
];
386391
}
387392

388393
/**
389-
* @param $productScheduled
390-
* @param $expectedProductReindexCall
394+
* @param bool $productScheduled
395+
* @param array $affectedIds
396+
* @param int|string $isAnchorOrig
397+
* @param int|string $isAnchor
398+
* @param int $expectedProductReindexCall
391399
*
392400
* @dataProvider reindexFlatDisabledTestDataProvider
393401
*/
394-
public function testReindexFlatDisabled($productScheduled, $expectedProductReindexCall)
395-
{
396-
$affectedProductIds = ["1", "2"];
397-
$this->category->setAffectedProductIds($affectedProductIds);
402+
public function testReindexFlatDisabled(
403+
$productScheduled,
404+
$affectedIds,
405+
$isAnchorOrig,
406+
$isAnchor,
407+
$expectedProductReindexCall
408+
) {
409+
$this->category->setAffectedProductIds($affectedIds);
410+
$this->category->setData('is_anchor', $isAnchor);
411+
$this->category->setOrigData('is_anchor', $isAnchorOrig);
412+
$this->category->setAffectedProductIds($affectedIds);
413+
398414
$pathIds = ['path/1/2', 'path/2/3'];
399415
$this->category->setData('path_ids', $pathIds);
400416
$this->category->setId('123');
@@ -403,8 +419,12 @@ public function testReindexFlatDisabled($productScheduled, $expectedProductReind
403419
->method('isFlatEnabled')
404420
->will($this->returnValue(false));
405421

406-
$this->productIndexer->expects($this->exactly(1))->method('isScheduled')->will($this->returnValue($productScheduled));
407-
$this->productIndexer->expects($this->exactly($expectedProductReindexCall))->method('reindexList')->with($pathIds);
422+
$this->productIndexer->expects($this->exactly(1))
423+
->method('isScheduled')
424+
->willReturn($productScheduled);
425+
$this->productIndexer->expects($this->exactly($expectedProductReindexCall))
426+
->method('reindexList')
427+
->with($pathIds);
408428

409429
$this->indexerRegistry->expects($this->at(0))
410430
->method('get')

app/code/Magento/Catalog/etc/product_options_merged.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
9-
<xs:redefine schemaLocation="product_options.xsd">
9+
<xs:redefine schemaLocation="urn:magento:module:Magento_Catalog:etc/product_options.xsd">
1010
<xs:complexType name="optionDeclaration">
1111
<xs:complexContent>
1212
<xs:restriction base="optionDeclaration">

0 commit comments

Comments
 (0)