Skip to content

Commit 7a47140

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into PR-bugfixes-040417
2 parents 1784bd3 + ed746e3 commit 7a47140

File tree

66 files changed

+1185
-742
lines changed

Some content is hidden

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

66 files changed

+1185
-742
lines changed

app/code/Magento/Bundle/Test/Unit/Block/Adminhtml/Sales/Order/View/Items/RendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function getSelectionAttributesDataProvider()
170170
{
171171
return [
172172
[[], null],
173-
[['bundle_selection_attributes' => 'a:1:{i:0;i:1;}'], [0 => 1]],
173+
[['bundle_selection_attributes' => 'serialized string'], [0 => 1]],
174174
];
175175
}
176176

app/code/Magento/Catalog/Setup/UpgradeData.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
/**
1717
* Upgrade Data script
18-
* @codeCoverageIgnore
18+
*
1919
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2020
*/
2121
class UpgradeData implements UpgradeDataInterface
@@ -35,15 +35,25 @@ class UpgradeData implements UpgradeDataInterface
3535
private $eavSetupFactory;
3636

3737
/**
38-
* Init
38+
* @var UpgradeWidgetData
39+
*/
40+
private $upgradeWidgetData;
41+
42+
/**
43+
* Constructor
3944
*
4045
* @param CategorySetupFactory $categorySetupFactory
4146
* @param EavSetupFactory $eavSetupFactory
47+
* @param UpgradeWidgetData $upgradeWidgetData
4248
*/
43-
public function __construct(CategorySetupFactory $categorySetupFactory, EavSetupFactory $eavSetupFactory)
44-
{
49+
public function __construct(
50+
CategorySetupFactory $categorySetupFactory,
51+
EavSetupFactory $eavSetupFactory,
52+
UpgradeWidgetData $upgradeWidgetData
53+
) {
4554
$this->categorySetupFactory = $categorySetupFactory;
4655
$this->eavSetupFactory = $eavSetupFactory;
56+
$this->upgradeWidgetData = $upgradeWidgetData;
4757
}
4858

4959
/**
@@ -366,6 +376,9 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
366376
$this->dissallowUsingHtmlForProductName($setup);
367377
}
368378

379+
if ($context->getVersion() && version_compare($context->getVersion(), '2.2.1') < 0) {
380+
$this->upgradeWidgetData->upgrade();
381+
}
369382
$setup->endSetup();
370383
}
371384

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Setup;
7+
8+
use Magento\Framework\DB\Select\QueryModifierFactory;
9+
use Magento\Widget\Setup\LayoutUpdateConverter;
10+
use Magento\Eav\Setup\EavSetup;
11+
use Magento\Framework\DB\FieldToConvert;
12+
use Magento\Framework\DB\AggregatedFieldDataConverter;
13+
14+
/**
15+
* Convert serialized widget data for categories and products tables to JSON
16+
*/
17+
class UpgradeWidgetData
18+
{
19+
/**
20+
* @var EavSetup
21+
*/
22+
private $eavSetup;
23+
24+
/**
25+
* @var QueryModifierFactory
26+
*/
27+
private $queryModifierFactory;
28+
29+
/**
30+
* Constructor
31+
*
32+
* @param EavSetup $eavSetup
33+
* @param QueryModifierFactory $queryModifierFactory
34+
* @param AggregatedFieldDataConverter $aggregatedFieldDataConverter
35+
*/
36+
public function __construct(
37+
EavSetup $eavSetup,
38+
QueryModifierFactory $queryModifierFactory,
39+
AggregatedFieldDataConverter $aggregatedFieldDataConverter
40+
) {
41+
$this->eavSetup = $eavSetup;
42+
$this->queryModifierFactory = $queryModifierFactory;
43+
$this->aggregatedFieldDataConverter = $aggregatedFieldDataConverter;
44+
}
45+
46+
/**
47+
* Convert category and product layout update
48+
*
49+
* @return void
50+
* @throws \InvalidArgumentException
51+
*/
52+
public function upgrade()
53+
{
54+
$categoryTypeId = $this->eavSetup->getEntityTypeId(\Magento\Catalog\Model\Category::ENTITY);
55+
$categoryLayoutUpdateAttribute = $this->eavSetup->getAttribute($categoryTypeId, 'custom_layout_update');
56+
$categoryLayoutUpdateAttributeModifier = $this->queryModifierFactory->create(
57+
'in',
58+
[
59+
'values' => [
60+
'attribute_id' => $categoryLayoutUpdateAttribute['attribute_id']
61+
]
62+
]
63+
);
64+
$layoutUpdateValueModifier = $this->queryModifierFactory->create(
65+
'like',
66+
[
67+
'values' => [
68+
'value' => '%conditions_encoded%'
69+
]
70+
]
71+
);
72+
$categoryLayoutUpdateModifier = $this->queryModifierFactory->create(
73+
'composite',
74+
[
75+
'queryModifiers' => [
76+
$categoryLayoutUpdateAttributeModifier,
77+
$layoutUpdateValueModifier
78+
]
79+
]
80+
);
81+
$productTypeId = $this->eavSetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
82+
$productLayoutUpdateAttribute = $this->eavSetup->getAttribute($productTypeId, 'custom_layout_update');
83+
$productLayoutUpdateAttributeModifier = $this->queryModifierFactory->create(
84+
'in',
85+
[
86+
'values' => [
87+
'attribute_id' => $productLayoutUpdateAttribute['attribute_id']
88+
]
89+
]
90+
);
91+
$productLayoutUpdateModifier = $this->queryModifierFactory->create(
92+
'composite',
93+
[
94+
'queryModifiers' => [
95+
$productLayoutUpdateAttributeModifier,
96+
$layoutUpdateValueModifier
97+
]
98+
]
99+
);
100+
$this->aggregatedFieldDataConverter->convert(
101+
[
102+
new FieldToConvert(
103+
LayoutUpdateConverter::class,
104+
$this->eavSetup->getSetup()->getTable('catalog_category_entity_text'),
105+
'value_id',
106+
'value',
107+
$categoryLayoutUpdateModifier
108+
),
109+
new FieldToConvert(
110+
LayoutUpdateConverter::class,
111+
$this->eavSetup->getSetup()->getTable('catalog_product_entity_text'),
112+
'value_id',
113+
'value',
114+
$productLayoutUpdateModifier
115+
),
116+
],
117+
$this->eavSetup->getSetup()->getConnection()
118+
);
119+
}
120+
}

app/code/Magento/Catalog/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Catalog" setup_version="2.2.0">
9+
<module name="Magento_Catalog" setup_version="2.2.1">
1010
<sequence>
1111
<module name="Magento_Eav"/>
1212
<module name="Magento_Cms"/>

app/code/Magento/CatalogRule/Setup/UpgradeData.php

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
namespace Magento\CatalogRule\Setup;
88

9-
use Magento\Framework\DB\FieldDataConverterFactory;
9+
use Magento\Framework\DB\AggregatedFieldDataConverter;
1010
use Magento\Framework\DB\DataConverter\SerializedToJson;
11+
use Magento\Framework\DB\FieldToConvert;
1112
use Magento\Framework\Setup\ModuleContextInterface;
1213
use Magento\Framework\Setup\ModuleDataSetupInterface;
1314
use Magento\Framework\Setup\UpgradeDataInterface;
@@ -17,26 +18,26 @@
1718
class UpgradeData implements UpgradeDataInterface
1819
{
1920
/**
20-
* @var FieldDataConverterFactory
21+
* @var MetadataPool
2122
*/
22-
private $fieldDataConverterFactory;
23+
private $metadataPool;
2324

2425
/**
25-
* @var MetadataPool
26+
* @var AggregatedFieldDataConverter
2627
*/
27-
private $metadataPool;
28+
private $aggregatedFieldConverter;
2829

2930
/**
3031
* UpgradeData constructor.
3132
*
32-
* @param FieldDataConverterFactory $fieldDataConverterFactory
33+
* @param AggregatedFieldDataConverter $aggregatedFieldConverter
3334
* @param MetadataPool $metadataPool
3435
*/
3536
public function __construct(
36-
FieldDataConverterFactory $fieldDataConverterFactory,
37+
AggregatedFieldDataConverter $aggregatedFieldConverter,
3738
MetadataPool $metadataPool
3839
) {
39-
$this->fieldDataConverterFactory = $fieldDataConverterFactory;
40+
$this->aggregatedFieldConverter = $aggregatedFieldConverter;
4041
$this->metadataPool = $metadataPool;
4142
}
4243

@@ -63,20 +64,23 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
6364
*/
6465
public function convertSerializedDataToJson($setup)
6566
{
66-
$fieldDataConverter = $this->fieldDataConverterFactory->create(SerializedToJson::class);
6767
$metadata = $this->metadataPool->getMetadata(RuleInterface::class);
68-
69-
$fieldDataConverter->convert(
70-
$setup->getConnection(),
71-
$setup->getTable('catalogrule'),
72-
$metadata->getLinkField(),
73-
'conditions_serialized'
74-
);
75-
$fieldDataConverter->convert(
76-
$setup->getConnection(),
77-
$setup->getTable('catalogrule'),
78-
$metadata->getLinkField(),
79-
'actions_serialized'
68+
$this->aggregatedFieldConverter->convert(
69+
[
70+
new FieldToConvert(
71+
SerializedToJson::class,
72+
$setup->getTable('catalogrule'),
73+
$metadata->getLinkField(),
74+
'conditions_serialized'
75+
),
76+
new FieldToConvert(
77+
SerializedToJson::class,
78+
$setup->getTable('catalogrule'),
79+
$metadata->getLinkField(),
80+
'actions_serialized'
81+
),
82+
],
83+
$setup->getConnection()
8084
);
8185
}
8286
}

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/_files/categoryUrlRewritesDataProvider.php

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)