Skip to content

Commit b2e5e71

Browse files
committed
Merge pull request #473 from magento-south/BUGS
[SOUTH] Bugfixes
2 parents 3cc19fe + 1df7174 commit b2e5e71

File tree

21 files changed

+431
-177
lines changed

21 files changed

+431
-177
lines changed

app/code/Magento/CatalogRule/Model/Rule/DataProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getData()
7474
$rule = $this->collection->getNewEmptyItem();
7575
$rule->setData($data);
7676
$this->loadedData[$rule->getId()] = $rule->getData();
77+
$this->dataPersistor->clear('catalog_rule');
7778
}
7879

7980
return $this->loadedData;

app/code/Magento/CatalogRule/Test/Unit/Model/Rule/DataProviderTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public function testGetDataIfRulePersisted()
8484
->method('get')
8585
->with('catalog_rule')
8686
->willReturn($persistedData);
87+
$this->dataPersistorMock->expects($this->once())
88+
->method('clear')
89+
->with('catalog_rule');
8790

8891
$newRuleMock = $this->getMock('Magento\CatalogRule\Model\Rule', [], [], '', false);
8992
$newRuleMock->expects($this->atLeastOnce())->method('setData')->with($persistedData)->willReturnSelf();

app/code/Magento/Cms/Controller/Adminhtml/Block/Index.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function execute()
3737
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
3838
$resultPage = $this->resultPageFactory->create();
3939
$this->initPage($resultPage)->getConfig()->getTitle()->prepend(__('Blocks'));
40+
41+
$dataPersistor = $this->_objectManager->get('Magento\Framework\App\Request\DataPersistorInterface');
42+
$dataPersistor->clear('cms_block');
43+
4044
return $resultPage;
4145
}
4246
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public function execute()
4949
$resultPage->addBreadcrumb(__('Manage Pages'), __('Manage Pages'));
5050
$resultPage->getConfig()->getTitle()->prepend(__('Pages'));
5151

52+
$dataPersistor = $this->_objectManager->get('Magento\Framework\App\Request\DataPersistorInterface');
53+
$dataPersistor->clear('cms_page');
54+
5255
return $resultPage;
5356
}
5457
}

app/code/Magento/Cms/Model/Block/DataProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getData()
7474
$block = $this->collection->getNewEmptyItem();
7575
$block->setData($data);
7676
$this->loadedData[$block->getId()] = $block->getData();
77+
$this->dataPersistor->clear('cms_block');
7778
}
7879

7980
return $this->loadedData;

app/code/Magento/Cms/Model/Page/DataProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public function getData()
7373
$page = $this->collection->getNewEmptyItem();
7474
$page->setData($data);
7575
$this->loadedData[$page->getId()] = $page->getData();
76+
$this->dataPersistor->clear('cms_page');
7677
}
7778

7879
return $this->loadedData;

app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_form.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@
142142
<item name="formElement" xsi:type="string">input</item>
143143
<item name="source" xsi:type="string">page</item>
144144
<item name="dataScope" xsi:type="string">identifier</item>
145-
<item name="validation" xsi:type="array">
146-
<item name="required-entry" xsi:type="boolean">true</item>
147-
</item>
148145
</item>
149146
</argument>
150147
</field>

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function isHidden()
133133
* Initialize the form.
134134
*
135135
* @return $this
136+
* @SuppressWarnings(PHPMD.NPathComplexity)
136137
*/
137138
public function initForm()
138139
{
@@ -166,6 +167,8 @@ public function initForm()
166167
$form->setValues(['subscription' => $isSubscribed ? 'true' : 'false']);
167168
$form->getElement('subscription')->setIsChecked($isSubscribed);
168169

170+
$this->updateFromSession($form, $customerId);
171+
169172
$changedDate = $this->getStatusChangedDate();
170173
if ($changedDate) {
171174
$fieldset->addField(
@@ -183,6 +186,24 @@ public function initForm()
183186
return $this;
184187
}
185188

189+
/**
190+
* Update form elements from session data
191+
*
192+
* @param \Magento\Framework\Data\Form $form
193+
* @param int $customerId
194+
* @return void
195+
*/
196+
protected function updateFromSession(\Magento\Framework\Data\Form $form, $customerId)
197+
{
198+
$data = $this->_backendSession->getCustomerFormData();
199+
if (!empty($data)) {
200+
$dataCustomerId = isset($data['customer']['entity_id']) ? $data['customer']['entity_id'] : null;
201+
if (isset($data['subscription']) && $dataCustomerId == $customerId) {
202+
$form->getElement('subscription')->setIsChecked($data['subscription']);
203+
}
204+
}
205+
}
206+
186207
/**
187208
* Retrieve the date when the subscriber status changed.
188209
*

app/code/Magento/Customer/Controller/Adminhtml/Index/Edit.php

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -49,77 +49,6 @@ public function execute()
4949
}
5050
}
5151
$customerData['customer_id'] = $customerId;
52-
53-
// set entered data if was error when we do save
54-
$data = $this->_getSession()->getCustomerData(true);
55-
56-
// restore data from SESSION
57-
if ($data && (!isset(
58-
$data['customer_id']
59-
) || isset(
60-
$data['customer_id']
61-
) && $data['customer_id'] == $customerId)
62-
) {
63-
$request = clone $this->getRequest();
64-
$request->setParams($data);
65-
66-
if (isset($data['account']) && is_array($data['account'])) {
67-
$customerForm = $this->_formFactory->create(
68-
'customer',
69-
'adminhtml_customer',
70-
$customerData['account'],
71-
true
72-
);
73-
$formData = $customerForm->extractData($request, 'account');
74-
$customerData['account'] = $customerForm->restoreData($formData);
75-
$customer = $this->customerDataFactory->create();
76-
$this->dataObjectHelper->populateWithArray(
77-
$customer,
78-
$customerData['account'],
79-
'\Magento\Customer\Api\Data\CustomerInterface'
80-
);
81-
}
82-
83-
if (isset($data['address']) && is_array($data['address'])) {
84-
foreach (array_keys($data['address']) as $addressId) {
85-
if ($addressId == '_template_') {
86-
continue;
87-
}
88-
89-
try {
90-
$address = $this->addressRepository->getById($addressId);
91-
if (empty($customerId) || $address->getCustomerId() != $customerId) {
92-
//reinitialize address data object
93-
$address = $this->addressDataFactory->create();
94-
}
95-
} catch (NoSuchEntityException $e) {
96-
$address = $this->addressDataFactory->create();
97-
$address->setId($addressId);
98-
}
99-
if (!empty($customerId)) {
100-
$address->setCustomerId($customerId);
101-
}
102-
$address->setIsDefaultBilling(
103-
!empty($data['account'][CustomerInterface::DEFAULT_BILLING]) &&
104-
$data['account'][CustomerInterface::DEFAULT_BILLING] == $addressId
105-
);
106-
$address->setIsDefaultShipping(
107-
!empty($data['account'][CustomerInterface::DEFAULT_SHIPPING]) &&
108-
$data['account'][CustomerInterface::DEFAULT_SHIPPING] == $addressId
109-
);
110-
$requestScope = sprintf('address/%s', $addressId);
111-
$addressForm = $this->_formFactory->create(
112-
'customer_address',
113-
'adminhtml_customer_address',
114-
$this->addressMapper->toFlatArray($address)
115-
);
116-
$formData = $addressForm->extractData($request, $requestScope);
117-
$customerData['address'][$addressId] = $addressForm->restoreData($formData);
118-
$customerData['address'][$addressId][\Magento\Customer\Api\Data\AddressInterface::ID] = $addressId;
119-
}
120-
}
121-
}
122-
12352
$this->_getSession()->setCustomerData($customerData);
12453

12554
$resultPage = $this->resultPageFactory->create();

app/code/Magento/Customer/Controller/Adminhtml/Index/Index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function execute()
3333
$resultPage->addBreadcrumb(__('Manage Customers'), __('Manage Customers'));
3434

3535
$this->_getSession()->unsCustomerData();
36+
$this->_getSession()->unsCustomerFormData();
3637

3738
return $resultPage;
3839
}

0 commit comments

Comments
 (0)