forked from ConvertGroupsAS/magento2-patches
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPatch-Magento_Widget-M2.1.0-widgets-restore-conditions.patch
74 lines (72 loc) · 2.97 KB
/
Patch-Magento_Widget-M2.1.0-widgets-restore-conditions.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
--- Controller/Adminhtml/Widget/LoadOptions.php 2016-10-11 00:27:56.000000000 +0300
+++ Controller/Adminhtml/Widget/LoadOptions.php 2017-02-21 22:59:01.000000000 +0300
@@ -6,9 +6,16 @@
*/
namespace Magento\Widget\Controller\Adminhtml\Widget;
+use Magento\Framework\App\ObjectManager;
+
class LoadOptions extends \Magento\Backend\App\Action
{
/**
+ * @var \Magento\Widget\Helper\Conditions
+ */
+ private $conditionsHelper;
+
+ /**
* Ajax responder for loading plugin options form
*
* @return void
@@ -18,13 +25,19 @@
try {
$this->_view->loadLayout();
if ($paramsJson = $this->getRequest()->getParam('widget')) {
- $request = $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonDecode($paramsJson);
+ $request = $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)
+ ->jsonDecode($paramsJson);
if (is_array($request)) {
$optionsBlock = $this->_view->getLayout()->getBlock('wysiwyg_widget.options');
if (isset($request['widget_type'])) {
$optionsBlock->setWidgetType($request['widget_type']);
}
if (isset($request['values'])) {
+ $request['values'] = array_map('htmlspecialchars_decode', $request['values']);
+ if (isset($request['values']['conditions_encoded'])) {
+ $request['values']['conditions'] =
+ $this->getConditionsHelper()->decode($request['values']['conditions_encoded']);
+ }
$optionsBlock->setWidgetValues($request['values']);
}
}
@@ -33,8 +46,21 @@
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$result = ['error' => true, 'message' => $e->getMessage()];
$this->getResponse()->representJson(
- $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result)
+ $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)->jsonEncode($result)
);
}
}
+
+ /**
+ * @return \Magento\Widget\Helper\Conditions
+ * @deprecated
+ */
+ private function getConditionsHelper()
+ {
+ if (!$this->conditionsHelper) {
+ $this->conditionsHelper = ObjectManager::getInstance()->get(\Magento\Widget\Helper\Conditions::class);
+ }
+
+ return $this->conditionsHelper;
+ }
}
--- Model/Widget.php 2016-10-11 00:27:56.000000000 +0300
+++ Model/Widget.php 2017-02-21 22:54:40.000000000 +0300
@@ -314,7 +314,7 @@
}
}
if ($value) {
- $directive .= sprintf(' %s="%s"', $name, $value);
+ $directive .= sprintf(' %s="%s"', $name, $this->escaper->escapeQuote($value));
}
}