Skip to content

Commit d964cf2

Browse files
author
Oleksii Korshenko
committed
Merge branch '2.0-develop' into MAGETWO-59676
2 parents 4eea8d8 + 60fcebc commit d964cf2

File tree

138 files changed

+5514
-1680
lines changed

Some content is hidden

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

138 files changed

+5514
-1680
lines changed

app/bootstrap.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
$mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002;
3636
umask($mask);
3737

38+
if (empty($_SERVER['ENABLE_IIS_REWRITES']) || ($_SERVER['ENABLE_IIS_REWRITES'] != 1)) {
39+
/*
40+
* Unset headers used by IIS URL rewrites.
41+
*/
42+
unset($_SERVER['HTTP_X_REWRITE_URL']);
43+
unset($_SERVER['HTTP_X_ORIGINAL_URL']);
44+
unset($_SERVER['IIS_WasUrlRewritten']);
45+
unset($_SERVER['UNENCODED_URL']);
46+
unset($_SERVER['ORIG_PATH_INFO']);
47+
}
48+
3849
if (!empty($_SERVER['MAGE_PROFILER'])
3950
&& isset($_SERVER['HTTP_ACCEPT'])
4051
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false

app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,19 @@ public function execute()
5252
$user->setPassword($password);
5353
$user->setPasswordConfirmation($passwordConfirmation);
5454
}
55-
$user->save();
56-
/** Send password reset email notification only when password was changed */
57-
if ($password !== '') {
58-
$user->sendPasswordResetNotificationEmail();
55+
$errors = $user->validate();
56+
if ($errors !== true && !empty($errors)) {
57+
foreach ($errors as $error) {
58+
$this->messageManager->addError($error);
59+
}
60+
} else {
61+
$user->save();
62+
/** Send password reset email notification only when password was changed */
63+
if ($password !== '') {
64+
$user->sendPasswordResetNotificationEmail();
65+
}
66+
$this->messageManager->addSuccess(__('You saved the account.'));
5967
}
60-
$this->messageManager->addSuccess(__('You saved the account.'));
6168
} catch (ValidatorException $e) {
6269
$this->messageManager->addMessages($e->getMessages());
6370
if ($e->getMessage()) {

app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ protected function setUp()
7676
$this->_userMock = $this->getMockBuilder('Magento\User\Model\User')
7777
->disableOriginalConstructor()
7878
->setMethods(
79-
['load', 'save', 'sendPasswordResetNotificationEmail', 'verifyIdentity', '__sleep', '__wakeup']
79+
[
80+
'load', 'save', 'sendPasswordResetNotificationEmail',
81+
'verifyIdentity', 'validate', '__sleep', '__wakeup'
82+
]
8083
)
8184
->getMock();
8285

@@ -193,6 +196,7 @@ public function testSaveAction()
193196

194197
$this->_userMock->expects($this->once())->method('save');
195198
$this->_userMock->expects($this->once())->method('verifyIdentity')->will($this->returnValue(true));
199+
$this->_userMock->expects($this->once())->method('validate')->willReturn(true);
196200
$this->_userMock->expects($this->once())->method('sendPasswordResetNotificationEmail');
197201

198202
$this->_requestMock->setParams($requestParams);

app/code/Magento/Backend/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"magento/framework": "100.0.*"
2222
},
2323
"type": "magento2-module",
24-
"version": "100.0.7",
24+
"version": "100.0.8",
2525
"license": [
2626
"OSL-3.0",
2727
"AFL-3.0"

app/code/Magento/Braintree/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"magento/module-checkout-agreements": "100.0.*"
2323
},
2424
"type": "magento2-module",
25-
"version": "100.0.6",
25+
"version": "100.0.7",
2626
"license": [
2727
"proprietary"
2828
],

app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function execute()
132132
$attributesData[$attributeCode] = $value;
133133
} elseif ($attribute->getFrontendInput() == 'multiselect') {
134134
// Check if 'Change' checkbox has been checked by admin for this attribute
135-
$isChanged = (bool)$this->getRequest()->getPost($attributeCode . '_checkbox');
135+
$isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode);
136136
if (!$isChanged) {
137137
unset($attributesData[$attributeCode]);
138138
continue;

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public function execute()
7373
$productTypeId = $this->getRequest()->getParam('type');
7474
if ($data) {
7575
try {
76-
$data = $this->unserializeData($data);
7776
$product = $this->initializationHelper->initialize($this->productBuilder->build($this->getRequest()));
7877
$this->productTypeManager->processProduct($product);
7978

@@ -158,29 +157,6 @@ public function execute()
158157
return $resultRedirect;
159158
}
160159

161-
/**
162-
* @param array $data
163-
* @return array
164-
*/
165-
private function unserializeData($data)
166-
{
167-
if (isset($data["configurable-matrix-serialized"])) {
168-
$configurableMatrixSerialized = $data["configurable-matrix-serialized"];
169-
if ($configurableMatrixSerialized != null && !empty($configurableMatrixSerialized)) {
170-
$data["variations-matrix"] = json_decode($configurableMatrixSerialized, true);
171-
unset($data["configurable-matrix-serialized"]);
172-
}
173-
}
174-
if (isset($data["associated_product_ids_serialized"])) {
175-
$associatedProductIdsSerialized = $data["associated_product_ids_serialized"];
176-
if ($associatedProductIdsSerialized != null && !empty($associatedProductIdsSerialized)) {
177-
$data["associated_product_ids"] = json_decode($associatedProductIdsSerialized, true);
178-
unset($data["associated_product_ids_serialized"]);
179-
}
180-
}
181-
return $data;
182-
}
183-
184160
/**
185161
* Notify customer when image was not deleted in specific case.
186162
* TODO: temporary workaround must be eliminated in MAGETWO-45306

app/code/Magento/Catalog/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"magento/module-catalog-sample-data": "Sample Data version:100.0.*"
3535
},
3636
"type": "magento2-module",
37-
"version": "100.0.9",
37+
"version": "100.0.10",
3838
"license": [
3939
"OSL-3.0",
4040
"AFL-3.0"

app/code/Magento/Checkout/Controller/Sidebar/RemoveItem.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@
1313
use Magento\Framework\Json\Helper\Data;
1414
use Magento\Framework\View\Result\PageFactory;
1515
use Psr\Log\LoggerInterface;
16+
use Magento\Framework\Data\Form\FormKey\Validator;
17+
use Magento\Framework\App\ObjectManager;
1618

19+
/**
20+
* Class RemoveItem
21+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22+
*/
1723
class RemoveItem extends Action
1824
{
1925
/**
@@ -36,6 +42,11 @@ class RemoveItem extends Action
3642
*/
3743
protected $resultPageFactory;
3844

45+
/**
46+
* @var Validator
47+
*/
48+
private $formKeyValidator;
49+
3950
/**
4051
* @param Context $context
4152
* @param Sidebar $sidebar
@@ -59,12 +70,17 @@ public function __construct(
5970
}
6071

6172
/**
73+
* Executes the main action of the controller
74+
*
6275
* @return $this
6376
*/
6477
public function execute()
6578
{
6679
$itemId = (int)$this->getRequest()->getParam('item_id');
6780
try {
81+
if (!$this->getFormKeyValidator()->validate($this->getRequest())) {
82+
throw new LocalizedException(__('We can\'t remove the item.'));
83+
}
6884
$this->sidebar->checkQuoteItem($itemId);
6985
$this->sidebar->removeQuoteItem($itemId);
7086
return $this->jsonResponse();
@@ -90,4 +106,18 @@ protected function jsonResponse($error = '')
90106
$this->jsonHelper->jsonEncode($response)
91107
);
92108
}
109+
110+
/**
111+
* Getter for FormKeyValidator
112+
*
113+
* @deprecated
114+
* @return Validator
115+
*/
116+
private function getFormKeyValidator()
117+
{
118+
if ($this->formKeyValidator === null) {
119+
$this->formKeyValidator = ObjectManager::getInstance()->get(Validator::class);
120+
}
121+
return $this->formKeyValidator;
122+
}
93123
}

app/code/Magento/Checkout/Controller/Sidebar/UpdateItemQty.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
use Magento\Framework\Exception\LocalizedException;
1313
use Magento\Framework\Json\Helper\Data;
1414
use Psr\Log\LoggerInterface;
15+
use Magento\Framework\Data\Form\FormKey\Validator;
16+
use \Magento\Framework\App\ObjectManager;
1517

18+
/**
19+
* Class UpdateItemQty
20+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
*/
1622
class UpdateItemQty extends Action
1723
{
1824
/**
@@ -30,6 +36,11 @@ class UpdateItemQty extends Action
3036
*/
3137
protected $jsonHelper;
3238

39+
/**
40+
* @var Validator
41+
*/
42+
private $formKeyValidator;
43+
3344
/**
3445
* @param Context $context
3546
* @param Sidebar $sidebar
@@ -50,6 +61,8 @@ public function __construct(
5061
}
5162

5263
/**
64+
* Executes the main action of the controller
65+
*
5366
* @return $this
5467
*/
5568
public function execute()
@@ -58,6 +71,9 @@ public function execute()
5871
$itemQty = (int)$this->getRequest()->getParam('item_qty');
5972

6073
try {
74+
if (!$this->getFormKeyValidator()->validate($this->getRequest())) {
75+
throw new LocalizedException(__('We can\'t update the shopping cart.'));
76+
}
6177
$this->sidebar->checkQuoteItem($itemId);
6278
$this->sidebar->updateQuoteItem($itemId, $itemQty);
6379
return $this->jsonResponse();
@@ -81,4 +97,18 @@ protected function jsonResponse($error = '')
8197
$this->jsonHelper->jsonEncode($this->sidebar->getResponseData($error))
8298
);
8399
}
100+
101+
/**
102+
* Getter for FormKeyValidator
103+
*
104+
* @deprecated
105+
* @return Validator
106+
*/
107+
private function getFormKeyValidator()
108+
{
109+
if ($this->formKeyValidator === null) {
110+
$this->formKeyValidator = ObjectManager::getInstance()->get(Validator::class);
111+
}
112+
return $this->formKeyValidator;
113+
}
84114
}

0 commit comments

Comments
 (0)