Skip to content

Commit 8313fc3

Browse files
committed
MAGETWO-91570: [2.2.x] - [Github]Can not save attribute #5907
- builds stabilization
1 parent 92e925e commit 8313fc3

File tree

4 files changed

+49
-13
lines changed

4 files changed

+49
-13
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ define([
181181
});
182182
}
183183
editForm.on('submit', function () {
184-
optionPanel.find('input')
185-
.each(function() {
184+
optionPanel.find('input')
185+
.each(function () {
186186
optionsValues.push(this.name + '=' + jQuery(this).val());
187187
});
188188
jQuery('<input>')

app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ define([
415415

416416
$(function () {
417417
var editForm = $('#edit_form');
418+
418419
$('#frontend_input').bind('change', function () {
419420
swatchProductAttributes.bindAttributeInputType();
420421
});
@@ -435,11 +436,11 @@ define([
435436
swatchVisualPanel = $('#swatch-visual-options-panel'),
436437
swatchTextPanel = $('#swatch-text-options-panel');
437438

438-
activePanel = swatchTextPanel.is(":visible") ? swatchTextPanel : swatchVisualPanel;
439+
activePanel = swatchTextPanel.is(':visible') ? swatchTextPanel : swatchVisualPanel;
439440

440441
activePanel
441442
.find('table input')
442-
.each(function() {
443+
.each(function () {
443444
swatchValues.push(this.name + '=' + $(this).val());
444445
});
445446

@@ -451,7 +452,7 @@ define([
451452
.val(JSON.stringify(swatchValues))
452453
.prependTo(editForm);
453454

454-
[swatchVisualPanel, swatchTextPanel].forEach(function(el) {
455+
[swatchVisualPanel, swatchTextPanel].forEach(function (el) {
455456
$(el).find('table')
456457
.replaceWith($('<div>').text($.mage.__('Sending swatch values as package.')));
457458
});

dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Swatches\Controller\Adminhtml\Product;
79

810
use Magento\Framework\Exception\LocalizedException;
@@ -20,7 +22,7 @@ class AttributeTest extends \Magento\TestFramework\TestCase\AbstractBackendContr
2022
*
2123
* @return string
2224
*/
23-
private function getRandomColor()
25+
private function getRandomColor() : string
2426
{
2527
return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
2628
}
@@ -31,7 +33,7 @@ private function getRandomColor()
3133
* @param int $optionsCount
3234
* @return array
3335
*/
34-
private function getSwatchVisualDataSet($optionsCount)
36+
private function getSwatchVisualDataSet(int $optionsCount) : array
3537
{
3638
$optionsData = [];
3739
$expectedOptionsLabels = [];
@@ -69,7 +71,7 @@ private function getSwatchVisualDataSet($optionsCount)
6971
* @param int $optionsCount
7072
* @return array
7173
*/
72-
private function getSwatchTextDataSet($optionsCount)
74+
private function getSwatchTextDataSet(int $optionsCount) : array
7375
{
7476
$optionsData = [];
7577
$expectedOptionsLabels = [];
@@ -106,7 +108,7 @@ private function getSwatchTextDataSet($optionsCount)
106108
*
107109
* @return array
108110
*/
109-
private function getAttributePreset()
111+
private function getAttributePreset() : array
110112
{
111113
return [
112114
'serialized_options' => '[]',
@@ -147,7 +149,7 @@ private function getAttributePreset()
147149
*
148150
* @return array
149151
*/
150-
public function getLargeSwatchesAmountAttributeData()
152+
public function getLargeSwatchesAmountAttributeData() : array
151153
{
152154
$maxInputVars = ini_get('max_input_vars');
153155
// Each option is at least 7 variables array for a visual swatch.
@@ -168,8 +170,11 @@ public function getLargeSwatchesAmountAttributeData()
168170
* @param array $expectedLabels
169171
* @return void
170172
*/
171-
public function testLargeOptionsDataSet($attributeData, $expectedOptionsCount, $expectedLabels)
172-
{
173+
public function testLargeOptionsDataSet(
174+
array $attributeData,
175+
int $expectedOptionsCount,
176+
array $expectedLabels
177+
) {
173178
$this->getRequest()->setPostValue($attributeData);
174179
$this->dispatch('backend/catalog/product_attribute/save');
175180
$entityTypeId = $this->_objectManager->create(

dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ class HhvmCompatibilityTest extends \PHPUnit\Framework\TestCase
4747
'serialize_precision',
4848
];
4949

50+
/**
51+
* Whitelist of variables allowed in files.
52+
*
53+
* @var array
54+
*/
55+
private $whitelistVarsInFiles = [
56+
'max_input_vars' => [
57+
'integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php',
58+
'integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php',
59+
]
60+
];
61+
62+
/**
63+
* Test allowed directives.
64+
*
65+
* @SuppressWarnings(PHPMD.NPathComplexity)
66+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
67+
*/
5068
public function testAllowedIniGetSetDirectives()
5169
{
5270
$deniedDirectives = [];
@@ -55,7 +73,19 @@ public function testAllowedIniGetSetDirectives()
5573
if ($fileDirectives) {
5674
$fileDeniedDirectives = array_diff($fileDirectives, $this->allowedDirectives);
5775
if ($fileDeniedDirectives) {
58-
$deniedDirectives[$file] = array_unique($fileDeniedDirectives);
76+
$deniedDirectivesInFile = array_unique($fileDeniedDirectives);
77+
foreach ($deniedDirectivesInFile as $key => $deniedDirective) {
78+
if (isset($this->whitelistVarsInFiles[$deniedDirective])) {
79+
foreach ($this->whitelistVarsInFiles[$deniedDirective] as $whitelistFile) {
80+
if (strpos($file, $whitelistFile) !== false) {
81+
unset($deniedDirectivesInFile[$key]);
82+
}
83+
}
84+
}
85+
}
86+
if ($deniedDirectivesInFile) {
87+
$deniedDirectives[$file] = $deniedDirectivesInFile;
88+
}
5989
}
6090
}
6191
}

0 commit comments

Comments
 (0)