Skip to content

Commit

Permalink
Merge pull request #786 from magento-south/BUGS
Browse files Browse the repository at this point in the history
Bugs
- MAGETWO-63022 [2.2] SCD does not work when multiple languages are specified.
- MAGETWO-62276 'State/Province' isn't changed to input after selecting 'United Kingdom' while filling address on checkout
- MAGETWO-63009 Jasmine test randomly fails on bamboo
- MAGETWO-54733 Unable to save product with all unchecked values for multiple select attribute #7687
- MAGETWO-59966 [SWAT][Magento Cloud] - Cache-miss when Fastly is enabled
- MAGETWO-60258 [Magento Cloud] - Product position set in the admin is not honored in the category when seen in the Frontend
  • Loading branch information
VladimirZaets authored Feb 1, 2017
2 parents 0aff845 + c5c0686 commit ca6ac76
Show file tree
Hide file tree
Showing 19 changed files with 456 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

class Full extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractAction
{
/**
* Whether to use main or temporary index table
*
* @var bool
*/
protected $useTempTable = false;

/**
* Refresh entities index
*
Expand Down
74 changes: 74 additions & 0 deletions app/code/Magento/Catalog/Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
$this->addSourceEntityIdToProductEavIndex($setup);
}

if (version_compare($context->getVersion(), '2.1.4', '<')) {
$this->recreateCatalogCategoryProductIndexTmpTable($setup);
}

$setup->endSetup();
}

Expand Down Expand Up @@ -375,4 +379,74 @@ private function addPercentageValueColumn(SchemaSetupInterface $setup)
]
);
}

/**
* Drop and recreate catalog_category_product_index_tmp table
*
* Before this update the catalog_category_product_index_tmp table was created without usage of PK
* and with engine=MEMORY. Such structure of catalog_category_product_index_tmp table causes
* issues with MySQL DB replication.
*
* To avoid replication issues this method drops catalog_category_product_index_tmp table
* and creates new one with PK and engine=InnoDB
*
* @param SchemaSetupInterface $setup
* @return void
*/
private function recreateCatalogCategoryProductIndexTmpTable(SchemaSetupInterface $setup)
{
$tableName = $setup->getTable('catalog_category_product_index_tmp');

// Drop catalog_category_product_index_tmp table
$setup->getConnection()->dropTable($tableName);

// Create catalog_category_product_index_tmp table with PK and engine=InnoDB
$table = $setup->getConnection()
->newTable($tableName)
->addColumn(
'category_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
'Category ID'
)
->addColumn(
'product_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
'Product ID'
)
->addColumn(
'position',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['nullable' => false, 'default' => '0'],
'Position'
)
->addColumn(
'is_parent',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'default' => '0'],
'Is Parent'
)
->addColumn(
'store_id',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false, 'primary' => true, 'default' => '0'],
'Store ID'
)
->addColumn(
'visibility',
\Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
['unsigned' => true, 'nullable' => false],
'Visibility'
)
->setComment('Catalog Category Product Indexer temporary table');

$setup->getConnection()->createTable($table);
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_Catalog" setup_version="2.1.3">
<module name="Magento_Catalog" setup_version="2.1.4">
<sequence>
<module name="Magento_Eav"/>
<module name="Magento_Cms"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function validate($object)
$data = $object->getData($attributeCode);
if (is_array($data)) {
$object->setData($attributeCode, implode(',', array_filter($data)));
} elseif (empty($data)) {
$object->setData($attributeCode, null);
}
return parent::validate($object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Backend;

class ArrayTest extends \PHPUnit_Framework_TestCase
class ArrayBackendTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend
Expand Down Expand Up @@ -37,9 +37,10 @@ protected function setUp()
public function testValidate($data)
{
$this->_attribute->expects($this->atLeastOnce())->method('getAttributeCode')->will($this->returnValue('code'));
$product = new \Magento\Framework\DataObject(['code' => $data]);
$product = new \Magento\Framework\DataObject(['code' => $data, 'empty' => '']);
$this->_model->validate($product);
$this->assertEquals('1,2,3', $product->getCode());
$this->assertEquals(null, $product->getEmpty());
}

public static function attributeValueDataProvider()
Expand Down
41 changes: 38 additions & 3 deletions app/code/Magento/Theme/Controller/Result/MessagePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public function __construct(
}

/**
* Set 'mage-messages' cookie
*
* Checks the result that controller actions must return. If result is not JSON type, then
* sets 'mage-messages' cookie.
*
* @param ResultInterface $subject
* @param ResultInterface $result
* @return ResultInterface
Expand All @@ -75,18 +80,48 @@ public function afterRenderResult(
ResultInterface $result
) {
if (!($subject instanceof Json)) {
$this->setCookie($this->getMessages());
}
return $result;
}

/**
* Set 'mage-messages' cookie with 'messages' array
*
* Checks the $messages argument. If $messages is not an empty array, then
* sets 'mage-messages' public cookie:
*
* Cookie Name: 'mage-messages';
* Cookie Duration: 1 year;
* Cookie Path: /;
* Cookie HTTP Only flag: FALSE. Cookie can be accessed by client-side APIs.
*
* The 'messages' list has format:
* [
* [
* 'type' => 'type_value',
* 'text' => 'cookie_value',
* ],
* ]
*
*
* @param array $messages List of Magento messages that must be set as 'mage-messages' cookie.
* @return void
*/
private function setCookie(array $messages)
{
if (!empty($messages)) {
$publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata();
$publicCookieMetadata->setDurationOneYear();
$publicCookieMetadata->setPath('/');
$publicCookieMetadata->setHttpOnly(false);

$this->cookieManager->setPublicCookie(
self::MESSAGES_COOKIES_NAME,
$this->jsonHelper->jsonEncode($this->getMessages()),
$this->jsonHelper->jsonEncode($messages),
$publicCookieMetadata
);
}

return $result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public function testAfterRenderResultJson()

public function testAfterRenderResult()
{

$existingMessages = [
[
'type' => 'message0type',
Expand Down Expand Up @@ -125,14 +124,14 @@ public function testAfterRenderResult()
)
->willReturn(\Zend_Json::encode($existingMessages));

$this->dataMock->expects($this->any())
$this->dataMock->expects($this->once())
->method('jsonDecode')
->willReturnCallback(
function ($data) {
return \Zend_Json::decode($data);
}
);
$this->dataMock->expects($this->any())
$this->dataMock->expects($this->exactly(2))
->method('jsonEncode')
->willReturnCallback(
function ($data) {
Expand Down Expand Up @@ -168,6 +167,56 @@ function ($data) {
$this->assertEquals($resultMock, $this->model->afterRenderResult($resultMock, $resultMock));
}

public function testAfterRenderResultWithNoMessages()
{
/** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $resultMock */
$resultMock = $this->getMockBuilder(Redirect::class)
->disableOriginalConstructor()
->getMock();

$this->cookieManagerMock->expects($this->once())
->method('getCookie')
->with(
MessagePlugin::MESSAGES_COOKIES_NAME,
\Zend_Json::encode([])
)
->willReturn(\Zend_Json::encode([]));

$this->dataMock->expects($this->once())
->method('jsonDecode')
->willReturnCallback(
function ($data) {
return \Zend_Json::decode($data);
}
);
$this->dataMock->expects($this->once())
->method('jsonEncode')
->willReturnCallback(
function ($data) {
return \Zend_Json::encode($data);
}
);

/** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
$collectionMock = $this->getMockBuilder(Collection::class)
->disableOriginalConstructor()
->getMock();
$collectionMock->expects($this->once())
->method('getItems')
->willReturn([]);

$this->managerMock->expects($this->once())
->method('getMessages')
->with(true, null)
->willReturn($collectionMock);

$this->cookieMetadataFactoryMock->expects($this->never())
->method('createPublicCookieMetadata')
->willReturn(null);

$this->assertEquals($resultMock, $this->model->afterRenderResult($resultMock, $resultMock));
}

public function testAfterRenderResultWithoutExisting()
{
$messageType = 'message1type';
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Ui/view/base/web/js/form/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ define([
function beforeSave(data, url, selectorPrefix, messagesClass) {
var save = $.Deferred();

data = utils.serialize(data);

data = utils.serialize(utils.filterFormData(data));
data['form_key'] = window.FORM_KEY;

if (!url || url === 'undefined') {
Expand Down
20 changes: 19 additions & 1 deletion app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ define([
return Select.extend({
defaults: {
size: 5,
elementTmpl: 'ui/form/element/multiselect'
elementTmpl: 'ui/form/element/multiselect',
listens: {
value: 'setDifferedFromDefault setPrepareToSendData'
}
},

/**
Expand All @@ -38,6 +41,21 @@ define([
return _.isString(value) ? value.split(',') : value;
},

/**
* Sets the prepared data to dataSource
* by path, where key is component link to dataSource with
* suffix "-prepared-for-send"
*
* @param {Array} data - current component value
*/
setPrepareToSendData: function (data) {
if (!data.length) {
data = '';
}

this.source.set(this.dataScope + '-prepared-for-send', data);
},

/**
* @inheritdoc
*/
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Ui/view/base/web/js/form/element/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ define([
if (_.isUndefined(caption)) {
caption = node.label;
}
} else {
return node;
}

return node;
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ class VirtualTest extends \PHPUnit_Framework_TestCase
'theme_title' => 'Test physical theme',
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'type' => ThemeInterface::TYPE_PHYSICAL,
'code' => 'physical',
],
'virtual' => [
'parent_id' => null,
'theme_path' => '',
'theme_title' => 'Test virtual theme',
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'type' => ThemeInterface::TYPE_VIRTUAL,
'code' => 'virtual',
],
'staging' => [
'parent_id' => null,
'theme_path' => '',
'theme_title' => 'Test staging theme',
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'type' => ThemeInterface::TYPE_STAGING,
'code' => 'staging',
],
];

Expand Down
Loading

0 comments on commit ca6ac76

Please sign in to comment.