From 7f0f260d3110a055ca1f8fa4886e766dd303b6c1 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Mon, 6 Jul 2020 15:37:39 +0300 Subject: [PATCH 01/11] magento2/issues/12087: Changes for Widget class. --- app/code/Magento/Widget/Model/Widget.php | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index d07e84186b2c9..bb6c0f22fefdf 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -304,6 +304,8 @@ public function getWidgetDeclaration($type, $params = [], $asIs = true) if ($name == 'conditions') { $name = 'conditions_encoded'; $value = $this->conditionsHelper->encode($value); + } elseif ($this->isTextType($widget, $name)) { + $value = $this->encodeReservedChars($value); } elseif (is_array($value)) { $value = implode(',', $value); } elseif (trim($value) == '') { @@ -456,4 +458,41 @@ protected function sortParameters($firstElement, $secondElement) $bOrder = (int)$secondElement->getData('sort_order'); return $aOrder < $bOrder ? -1 : ($aOrder > $bOrder ? 1 : 0); } + + /** + * @param $string + * @return string|string[] + */ + private function encodeReservedChars($string) + { + $map = [ + '{' => urlencode('{'), + '}' => urlencode('}') + ]; + + return str_replace( + array_keys($map), + array_values($map), + $string + ); + } + + /** + * @param $widget + * @param $name + * @return bool + */ + private function isTextType($widget, $name) + { + $parameters = $widget->getParameters(); + + if (isset($parameters[$name]) && is_object($parameters[$name])) { + $type = $parameters[$name]->getType(); + if ($type == 'text') { + return true; + } + } + + return false; + } } From 2a48abee8a17331fdea9d3ba4738e5394d73a13b Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Mon, 6 Jul 2020 16:07:05 +0300 Subject: [PATCH 02/11] magento2/issues/12087: Changes for Adminhtml Widget Options class. --- .../Widget/Block/Adminhtml/Widget/Options.php | 4 ++++ app/code/Magento/Widget/Model/Widget.php | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php b/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php index 32bae10c801c8..87ae52b2eadda 100644 --- a/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php +++ b/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php @@ -158,6 +158,10 @@ protected function _addField($parameter) $data['value'] = $parameter->getValue(); } + if ($parameter->getType() == 'text' && $data['value'] != '') { + $data['value'] = $this->_widget->decodeReservedChars($data['value']); + } + //prepare unique id value if ($fieldName == 'unique_id' && $data['value'] == '') { $data['value'] = hash('sha256', microtime(1)); diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index bb6c0f22fefdf..12af534325224 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -477,6 +477,24 @@ private function encodeReservedChars($string) ); } + /** + * @param $string + * @return array + */ + public function decodeReservedChars($string) + { + $map = [ + '{' => urlencode('{'), + '}' => urlencode('}') + ]; + + return str_replace( + array_values($map), + array_keys($map), + $string + ); + } + /** * @param $widget * @param $name From cb0b3d407dc1ac5c42e202a515a2aee97574b57d Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 7 Jul 2020 11:01:36 +0300 Subject: [PATCH 03/11] magento2/issues/12087: Fix static test. --- app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php | 1 + app/code/Magento/Widget/Model/Widget.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php b/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php index 87ae52b2eadda..44c43055df8b9 100644 --- a/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php +++ b/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php @@ -136,6 +136,7 @@ public function addFields() * @return \Magento\Framework\Data\Form\Element\AbstractElement * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _addField($parameter) { diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index 12af534325224..c01d8b226197d 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -293,6 +293,7 @@ public function getWidgetsArray($filters = []) * @param array $params Pre-configured Widget Params * @param bool $asIs Return result as widget directive(true) or as placeholder image(false) * @return string Widget directive ready to parse + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getWidgetDeclaration($type, $params = [], $asIs = true) { @@ -460,6 +461,8 @@ protected function sortParameters($firstElement, $secondElement) } /** + * Encode reserved chars + * * @param $string * @return string|string[] */ @@ -478,6 +481,8 @@ private function encodeReservedChars($string) } /** + * Decode reserved chars + * * @param $string * @return array */ @@ -496,6 +501,8 @@ public function decodeReservedChars($string) } /** + * Is text type Widget parameter + * * @param $widget * @param $name * @return bool From 1f84319d6905dc9cc862fd0cb1244489b44f5052 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 7 Jul 2020 14:39:30 +0300 Subject: [PATCH 04/11] magento2/issues/12087: Fix static test. --- app/code/Magento/Widget/Model/Widget.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index c01d8b226197d..49450ff6e017e 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -131,6 +131,7 @@ public function getWidgetByClassType($type) */ public function getConfigAsXml($type) { + // phpstan:ignore return $this->getXmlElementByType($type); } @@ -463,7 +464,7 @@ protected function sortParameters($firstElement, $secondElement) /** * Encode reserved chars * - * @param $string + * @param string $string * @return string|string[] */ private function encodeReservedChars($string) @@ -483,7 +484,7 @@ private function encodeReservedChars($string) /** * Decode reserved chars * - * @param $string + * @param string $string * @return array */ public function decodeReservedChars($string) @@ -503,8 +504,8 @@ public function decodeReservedChars($string) /** * Is text type Widget parameter * - * @param $widget - * @param $name + * @param \Magento\Framework\DataObject $widget + * @param string $name * @return bool */ private function isTextType($widget, $name) From ae3d3df4752dfcac5256ddb5014ce02b19e8a529 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Fri, 28 Aug 2020 16:28:54 +0300 Subject: [PATCH 05/11] fix widget with special char page tittle --- .../Widget/Block/Adminhtml/Widget/Options.php | 5 - app/code/Magento/Widget/Model/Widget.php | 197 ++++++++---------- 2 files changed, 85 insertions(+), 117 deletions(-) diff --git a/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php b/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php index 44c43055df8b9..32bae10c801c8 100644 --- a/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php +++ b/app/code/Magento/Widget/Block/Adminhtml/Widget/Options.php @@ -136,7 +136,6 @@ public function addFields() * @return \Magento\Framework\Data\Form\Element\AbstractElement * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _addField($parameter) { @@ -159,10 +158,6 @@ protected function _addField($parameter) $data['value'] = $parameter->getValue(); } - if ($parameter->getType() == 'text' && $data['value'] != '') { - $data['value'] = $this->_widget->decodeReservedChars($data['value']); - } - //prepare unique id value if ($fieldName == 'unique_id' && $data['value'] == '') { $data['value'] = hash('sha256', microtime(1)); diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index 3ca52cec43f40..6d9bb1878708a 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -5,6 +5,16 @@ */ namespace Magento\Widget\Model; +use Magento\Framework\App\Cache\Type\Config; +use Magento\Framework\DataObject; +use Magento\Framework\Escaper; +use Magento\Framework\Math\Random; +use Magento\Framework\View\Asset\Repository; +use Magento\Framework\View\Asset\Source; +use Magento\Framework\View\FileSystem; +use Magento\Widget\Helper\Conditions; +use Magento\Widget\Model\Config\Data; + /** * Widget model for different purposes * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -15,32 +25,32 @@ class Widget { /** - * @var \Magento\Widget\Model\Config\Data + * @var Data */ protected $dataStorage; /** - * @var \Magento\Framework\App\Cache\Type\Config + * @var Config */ protected $configCacheType; /** - * @var \Magento\Framework\View\Asset\Repository + * @var Repository */ protected $assetRepo; /** - * @var \Magento\Framework\View\Asset\Source + * @var Source */ protected $assetSource; /** - * @var \Magento\Framework\View\FileSystem + * @var FileSystem */ protected $viewFileSystem; /** - * @var \Magento\Framework\Escaper + * @var Escaper */ protected $escaper; @@ -50,30 +60,35 @@ class Widget protected $widgetsArray = []; /** - * @var \Magento\Widget\Helper\Conditions + * @var Conditions */ protected $conditionsHelper; /** - * @var \Magento\Framework\Math\Random + * @var Random */ private $mathRandom; /** - * @param \Magento\Framework\Escaper $escaper - * @param \Magento\Widget\Model\Config\Data $dataStorage - * @param \Magento\Framework\View\Asset\Repository $assetRepo - * @param \Magento\Framework\View\Asset\Source $assetSource - * @param \Magento\Framework\View\FileSystem $viewFileSystem - * @param \Magento\Widget\Helper\Conditions $conditionsHelper + * @var string[] + */ + private $reservedChars = ['}', '{']; + + /** + * @param Escaper $escaper + * @param Data $dataStorage + * @param Repository $assetRepo + * @param Source $assetSource + * @param FileSystem $viewFileSystem + * @param Conditions $conditionsHelper */ public function __construct( - \Magento\Framework\Escaper $escaper, - \Magento\Widget\Model\Config\Data $dataStorage, - \Magento\Framework\View\Asset\Repository $assetRepo, - \Magento\Framework\View\Asset\Source $assetSource, - \Magento\Framework\View\FileSystem $viewFileSystem, - \Magento\Widget\Helper\Conditions $conditionsHelper + Escaper $escaper, + Data $dataStorage, + Repository $assetRepo, + Source $assetSource, + FileSystem $viewFileSystem, + Conditions $conditionsHelper ) { $this->escaper = $escaper; $this->dataStorage = $dataStorage; @@ -110,14 +125,11 @@ public function getWidgetByClassType($type) $widgets = $this->getWidgets(); /** @var array $widget */ foreach ($widgets as $widget) { - if (isset($widget['@'])) { - if (isset($widget['@']['type'])) { - if ($type === $widget['@']['type']) { - return $widget; - } - } + if (isset($widget['@']['type']) && $type === $widget['@']['type']) { + return $widget; } } + return null; } @@ -131,8 +143,7 @@ public function getWidgetByClassType($type) */ public function getConfigAsXml($type) { - // phpstan:ignore - return $this->getXmlElementByType($type); + return $this->getWidgetByClassType($type); } /** @@ -294,48 +305,71 @@ public function getWidgetsArray($filters = []) * @param array $params Pre-configured Widget Params * @param bool $asIs Return result as widget directive(true) or as placeholder image(false) * @return string Widget directive ready to parse - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getWidgetDeclaration($type, $params = [], $asIs = true) { - $directive = '{{widget type="' . $type . '"'; $widget = $this->getConfigAsObject($type); + $directiveParams = ''; foreach ($params as $name => $value) { // Retrieve default option value if pre-configured - if ($name == 'conditions') { - $name = 'conditions_encoded'; - $value = $this->conditionsHelper->encode($value); - } elseif ($this->isTextType($widget, $name)) { - $value = $this->encodeReservedChars($value); - } elseif (is_array($value)) { - $value = implode(',', $value); - } elseif (trim($value) == '') { - $parameters = $widget->getParameters(); - if (isset($parameters[$name]) && is_object($parameters[$name])) { - $value = $parameters[$name]->getValue(); - } - } - if (isset($value)) { - $directive .= sprintf(' %s="%s"', $name, $this->escaper->escapeHtmlAttr($value, false)); - } + $directiveParams .= $this->getDirectiveParam($widget, $name, $value); } - $directive .= $this->getWidgetPageVarName($params); - - $directive .= '}}'; + $directive = sprintf('{{widget type="%s"%s%s}}', $type, $directiveParams, $this->getWidgetPageVarName($params)); if ($asIs) { return $directive; } - $html = sprintf( + return sprintf( '', $this->idEncode($directive), $this->getPlaceholderImageUrl($type), $this->escaper->escapeUrl($directive) ); - return $html; + } + + /** + * Returns directive param with prepared value + * + * @param DataObject $widget + * @param string $name + * @param string|array $value + * @return string + */ + private function getDirectiveParam(DataObject $widget, string $name, $value): string + { + if ($name === 'conditions') { + $name = 'conditions_encoded'; + $value = $this->conditionsHelper->encode($value); + } elseif (is_array($value)) { + $value = implode(',', $value); + } elseif (trim($value) === '') { + $parameters = $widget->getParameters(); + if (isset($parameters[$name]) && is_object($parameters[$name])) { + $value = $parameters[$name]->getValue(); + } + } else { + $value = $this->getPreparedValue($value); + } + + return $value !== null + ? sprintf(' %s="%s"', $name, $this->escaper->escapeHtmlAttr($value, false)) + : ''; + } + + /** + * Returns encoded value if it contains reserved chars + * + * @param string $value + * @return string + */ + private function getPreparedValue(string $value): string + { + $pattern = sprintf('/%s/', implode('|', $this->reservedChars)); + + return preg_match($pattern, $value) ? rawurlencode($value) : $value; } /** @@ -460,65 +494,4 @@ protected function sortParameters($firstElement, $secondElement) $bOrder = (int)$secondElement->getData('sort_order'); return $aOrder < $bOrder ? -1 : ($aOrder > $bOrder ? 1 : 0); } - - /** - * Encode reserved chars - * - * @param string $string - * @return string|string[] - */ - private function encodeReservedChars($string) - { - $map = [ - '{' => urlencode('{'), - '}' => urlencode('}') - ]; - - return str_replace( - array_keys($map), - array_values($map), - $string - ); - } - - /** - * Decode reserved chars - * - * @param string $string - * @return array - */ - public function decodeReservedChars($string) - { - $map = [ - '{' => urlencode('{'), - '}' => urlencode('}') - ]; - - return str_replace( - array_values($map), - array_keys($map), - $string - ); - } - - /** - * Is text type Widget parameter - * - * @param \Magento\Framework\DataObject $widget - * @param string $name - * @return bool - */ - private function isTextType($widget, $name) - { - $parameters = $widget->getParameters(); - - if (isset($parameters[$name]) && is_object($parameters[$name])) { - $type = $parameters[$name]->getType(); - if ($type == 'text') { - return true; - } - } - - return false; - } } From a2346f4697a76f1d9905dc9968a79b57a9909e2b Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Mon, 31 Aug 2020 10:53:52 +0300 Subject: [PATCH 06/11] refactor --- app/code/Magento/Widget/Model/Widget.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index 6d9bb1878708a..ec948063234da 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -313,7 +313,7 @@ public function getWidgetDeclaration($type, $params = [], $asIs = true) $directiveParams = ''; foreach ($params as $name => $value) { // Retrieve default option value if pre-configured - $directiveParams .= $this->getDirectiveParam($widget, $name, $value); + $directiveParams .= $value === null ? '' : $this->getDirectiveParam($widget, $name, $value); } $directive = sprintf('{{widget type="%s"%s%s}}', $type, $directiveParams, $this->getWidgetPageVarName($params)); @@ -354,9 +354,7 @@ private function getDirectiveParam(DataObject $widget, string $name, $value): st $value = $this->getPreparedValue($value); } - return $value !== null - ? sprintf(' %s="%s"', $name, $this->escaper->escapeHtmlAttr($value, false)) - : ''; + return sprintf(' %s="%s"', $name, $this->escaper->escapeHtmlAttr($value, false)); } /** From 74325ef39fd1c1e4e957747dc2d29ca3e73f4cf8 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Fri, 4 Sep 2020 15:46:53 +0300 Subject: [PATCH 07/11] minor refactor --- app/code/Magento/Widget/Model/Widget.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index ec948063234da..72f7dd77577af 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -310,10 +310,14 @@ public function getWidgetDeclaration($type, $params = [], $asIs = true) { $widget = $this->getConfigAsObject($type); + $params = array_filter($params, function ($value) { + return $value !== null; + }); + $directiveParams = ''; foreach ($params as $name => $value) { // Retrieve default option value if pre-configured - $directiveParams .= $value === null ? '' : $this->getDirectiveParam($widget, $name, $value); + $directiveParams .= $this->getDirectiveParam($widget, $name, $value); } $directive = sprintf('{{widget type="%s"%s%s}}', $type, $directiveParams, $this->getWidgetPageVarName($params)); From 0ac2e5d691f5bccbdb2fba896bb1c22ff6a0fa80 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Fri, 4 Sep 2020 15:47:29 +0300 Subject: [PATCH 08/11] mftf coverage --- ...alogProductsListWidgetTitleActionGroup.xml | 22 ++++++++ ...StorefrontAssertWidgetTitleActionGroup.xml | 26 ++++++++++ .../InsertWidgetSection.xml | 1 + ...eFrontWidgetTitleWithReservedCharsTest.xml | 52 +++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetTitleActionGroup.xml create mode 100644 app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/StorefrontAssertWidgetTitleActionGroup.xml create mode 100644 app/code/Magento/Cms/Test/Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml diff --git a/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetTitleActionGroup.xml b/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetTitleActionGroup.xml new file mode 100644 index 0000000000000..e146506d51a24 --- /dev/null +++ b/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetTitleActionGroup.xml @@ -0,0 +1,22 @@ + + + + + + + Fill catalog products list title field. + + + + + + + + + diff --git a/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/StorefrontAssertWidgetTitleActionGroup.xml b/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/StorefrontAssertWidgetTitleActionGroup.xml new file mode 100644 index 0000000000000..4505680424471 --- /dev/null +++ b/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/StorefrontAssertWidgetTitleActionGroup.xml @@ -0,0 +1,26 @@ + + + + + + + Assert widget title on storefront. + + + + + + + + $grabWidgetTitle + {{title}} + + + diff --git a/app/code/Magento/CatalogWidget/Test/Mftf/Section/CatalogWidgetSection/InsertWidgetSection.xml b/app/code/Magento/CatalogWidget/Test/Mftf/Section/CatalogWidgetSection/InsertWidgetSection.xml index 9b40971611d6f..3d8d5ecc1cda9 100644 --- a/app/code/Magento/CatalogWidget/Test/Mftf/Section/CatalogWidgetSection/InsertWidgetSection.xml +++ b/app/code/Magento/CatalogWidget/Test/Mftf/Section/CatalogWidgetSection/InsertWidgetSection.xml @@ -19,5 +19,6 @@ + diff --git a/app/code/Magento/Cms/Test/Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml new file mode 100644 index 0000000000000..4cfdc8197ad84 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml @@ -0,0 +1,52 @@ + + + + + + + + + <description value="See CMS Page title on store front page if titled widget with reserved chairs added"/> + <severity value="MAJOR"/> + <group value="Cms"/> + <group value="WYSIWYGDisabled"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <createData entity="simpleProductWithoutCategory" stepKey="createSimpleProductWithoutCategory"/> + <createData entity="_defaultCmsPage" stepKey="createCmsPage"/> + </before> + <after> + <deleteData createDataKey="createSimpleProductWithoutCategory" stepKey="deleteProduct"/> + <deleteData createDataKey="createCmsPage" stepKey="deleteCmsPage" /> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + <!--Navigate to Page in Admin--> + <actionGroup ref="NavigateToCreatedCMSPageActionGroup" stepKey="navigateToCreatedCMSPage"> + <argument name="CMSPage" value="$createCmsPage$"/> + </actionGroup> + <!--Insert widget--> + <actionGroup ref="AdminInsertWidgetToCmsPageContentActionGroup" stepKey="insertWidgetToCmsPageContent"> + <argument name="widgetType" value="Catalog Products List"/> + </actionGroup> + <!--Fill widget title and save--> + <actionGroup ref="AdminFillCatalogProductsListWidgetTitleActionGroup" stepKey="fillWidgetTitle"> + <argument name="title" value="Tittle }}"/> + </actionGroup> + <actionGroup ref="AdminClickInsertWidgetActionGroup" stepKey="clickInsertWidgetButton"/> + <actionGroup ref="SaveCmsPageActionGroup" stepKey="saveOpenedPage"/> + <!--Verify data on frontend--> + <actionGroup ref="StorefrontGoToCMSPageActionGroup" stepKey="navigateToPageOnStorefront"> + <argument name="identifier" value="$createCmsPage.identifier$"/> + </actionGroup> + <actionGroup ref="StorefrontAssertWidgetTitleActionGroup" stepKey="verifyPageDataOnFrontend"> + <argument name="title" value="Tittle }}"/> + </actionGroup> + </test> +</tests> From edd340130b92015e3ecd6e03e93ca75111610afe Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Mon, 7 Sep 2020 13:55:55 +0300 Subject: [PATCH 09/11] improve array filter --- app/code/Magento/Widget/Model/Widget.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index 72f7dd77577af..c8b13ef028592 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -311,7 +311,7 @@ public function getWidgetDeclaration($type, $params = [], $asIs = true) $widget = $this->getConfigAsObject($type); $params = array_filter($params, function ($value) { - return $value !== null; + return $value !== null && $value !== ''; }); $directiveParams = ''; From ace8a6fd54d920b01533668f7f0b2942ec4b3def Mon Sep 17 00:00:00 2001 From: Vadim Malesh <51680850+engcom-Charlie@users.noreply.github.com> Date: Tue, 8 Sep 2020 09:48:44 +0300 Subject: [PATCH 10/11] add testCaseId --- .../Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Cms/Test/Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml index 4cfdc8197ad84..bc379ec424fce 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/StoreFrontWidgetTitleWithReservedCharsTest.xml @@ -14,6 +14,7 @@ <title value="Create CMS Page via the Admin when widget title contains reserved chairs"/> <description value="See CMS Page title on store front page if titled widget with reserved chairs added"/> <severity value="MAJOR"/> + <testCaseId value="MC-37419"/> <group value="Cms"/> <group value="WYSIWYGDisabled"/> </annotations> From 01b7906cd3e339c0467f6cc9af6d681c7627482b Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Wed, 9 Sep 2020 13:32:33 +0300 Subject: [PATCH 11/11] revert changing the obsolete method --- app/code/Magento/Widget/Model/Widget.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Widget/Model/Widget.php b/app/code/Magento/Widget/Model/Widget.php index c8b13ef028592..b05b70cfcbc71 100644 --- a/app/code/Magento/Widget/Model/Widget.php +++ b/app/code/Magento/Widget/Model/Widget.php @@ -143,7 +143,8 @@ public function getWidgetByClassType($type) */ public function getConfigAsXml($type) { - return $this->getWidgetByClassType($type); + // phpstan:ignore + return $this->getXmlElementByType($type); } /**