Skip to content

Commit f23787e

Browse files
committed
MC-39953: After changing the layout the theme doesn't apply
1 parent 3b397a9 commit f23787e

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public function execute()
8383
/** @var \Magento\Cms\Model\Page $page */
8484
$page = $this->pageRepository->getById($pageId);
8585
try {
86-
$pageData = $this->filterPost($postItems[$pageId]);
87-
$this->validatePost($pageData, $page, $error, $messages);
8886
$extendedPageData = $page->getData();
87+
$pageData = $this->filterPostWithoutDate($postItems[$pageId], $extendedPageData);
88+
$this->validatePost($pageData, $page, $error, $messages);
8989
$this->setCmsPageData($page, $extendedPageData, $pageData);
9090
$this->pageRepository->save($page);
9191
} catch (\Magento\Framework\Exception\LocalizedException $e) {
@@ -127,6 +127,32 @@ protected function filterPost($postData = [])
127127
return $pageData;
128128
}
129129

130+
/**
131+
* Filtering posted data without changing custom theme dates
132+
*
133+
* @param array $postData
134+
* @param array $pageData
135+
* @return array
136+
*/
137+
private function filterPostWithoutDate($postData = [], $pageData = [])
138+
{
139+
$newPageData = $this->filterPost($postData);
140+
if (
141+
!empty($newPageData['custom_theme_from']) &&
142+
date("Y-m-d", strtotime($postData['custom_theme_from'])) ===
143+
date("Y-m-d", strtotime($pageData['custom_theme_from']))
144+
) {
145+
$newPageData['custom_theme_from'] = date("Y-m-d", strtotime($postData['custom_theme_from']));
146+
} elseif (
147+
!empty($newPageData['custom_theme_to']) &&
148+
date("Y-m-d", strtotime($postData['custom_theme_to'])) ===
149+
date("Y-m-d", strtotime($pageData['custom_theme_to']))
150+
) {
151+
$newPageData['custom_theme_to'] = date("Y-m-d", strtotime($postData['custom_theme_to']));
152+
}
153+
return $newPageData;
154+
}
155+
130156
/**
131157
* Validate post data
132158
*

0 commit comments

Comments
 (0)