Skip to content

Commit 7263c0f

Browse files
author
Joan He
committed
MAGETWO-66318: Remove usages of serialize/unserialize in CmsSampleData
- address review comments
1 parent 4c44d3c commit 7263c0f

File tree

4 files changed

+11
-21
lines changed

4 files changed

+11
-21
lines changed

app/code/Magento/Cms/Setup/ContentConverter.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Magento\Framework\DB\DataConverter\SerializedToJson;
1111
use Magento\Framework\Serialize\Serializer\Json;
1212
use Magento\Framework\Serialize\Serializer\Serialize;
13-
use Magento\Widget\Helper\Conditions;
1413

1514
/**
1615
* Convert conditions_encoded part of cms block content data from serialized to JSON format
@@ -71,17 +70,6 @@ public function convert($value)
7170
return $convertedValue;
7271
}
7372

74-
/**
75-
* Check if conditions have been converted to JSON
76-
*
77-
* @param string $value
78-
* @return bool
79-
*/
80-
private function isConvertedConditions($value)
81-
{
82-
return $this->isValidJsonValue($this->normalizer->restoreReservedCharaters($value));
83-
}
84-
8573
/**
8674
* Convert widget parameters from serialized format to JSON format
8775
*
@@ -95,14 +83,13 @@ private function convertWidgetParams($paramsString)
9583
$tokenizer->setString($paramsString);
9684
$widgetParameters = $tokenizer->tokenize();
9785
if (isset($widgetParameters['conditions_encoded'])) {
98-
if ($this->isConvertedConditions($widgetParameters['conditions_encoded'])) {
86+
$conditions = $this->normalizer->restoreReservedCharaters($widgetParameters['conditions_encoded']);
87+
if ($this->isValidJsonValue($conditions)) {
9988
return $paramsString;
10089
}
101-
// Restore WYSIWYG reserved characters in string
102-
$conditions = $this->normalizer->restoreReservedCharaters($widgetParameters['conditions_encoded']);
103-
$conditions = parent::convert($conditions);
104-
// Replace WYSIWYG reserved characters in string
105-
$widgetParameters['conditions_encoded'] = $this->normalizer->replaceReservedCharaters($conditions);
90+
$widgetParameters['conditions_encoded'] = $this->normalizer->replaceReservedCharaters(
91+
parent::convert($conditions)
92+
);
10693
$newParamsString = '';
10794
foreach ($widgetParameters as $key => $parameter) {
10895
$newParamsString .= ' ' . $key . '="' . $parameter . '"';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private function convertWidgetConditionsToJson(ModuleDataSetupInterface $setup)
9292
'like',
9393
[
9494
'values' => [
95-
'content' => ['%conditions_encoded%']
95+
'content' => '%conditions_encoded%'
9696
]
9797
]
9898
);

app/code/Magento/Widget/Model/Widget/Wysiwyg/Normalizer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\Widget\Model\Widget\Wysiwyg;
77

8+
/**
9+
* Normalize widget content in Wysiwyg editor
10+
*/
811
class Normalizer
912
{
1013

@@ -31,7 +34,7 @@ public function replaceReservedCharaters($content)
3134
}
3235

3336
/**
34-
* Restore the reserved characters in the content
37+
* Restore the reserved characters in the content
3538
*
3639
* @param string $content
3740
* @return string

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private function upgradeVersionTwoZeroOne(ModuleDataSetupInterface $setup)
7373
'like',
7474
[
7575
'values' => [
76-
'xml' => ['%conditions_encoded%']
76+
'xml' => '%conditions_encoded%'
7777
]
7878
]
7979
);

0 commit comments

Comments
 (0)