Skip to content

Commit f264b89

Browse files
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into develop
2 parents 054427c + 2ea8cdd commit f264b89

File tree

215 files changed

+8100
-2400
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+8100
-2400
lines changed

.htaccess

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@
243243
order allow,deny
244244
deny from all
245245
</Files>
246-
<Files CONTRIBUTOR_LICENSE_AGREEMENT.html>
247-
order allow,deny
248-
deny from all
249-
</Files>
250246
<Files COPYING.txt>
251247
order allow,deny
252248
deny from all

.htaccess.sample

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@
209209
order allow,deny
210210
deny from all
211211
</Files>
212-
<Files CONTRIBUTOR_LICENSE_AGREEMENT.html>
213-
order allow,deny
214-
deny from all
215-
</Files>
216212
<Files COPYING.txt>
217213
order allow,deny
218214
deny from all

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Magento 2 development team will review all issues and contributions submitte
1010

1111
## Contribution requirements
1212

13-
1. Contributions must adhere to [Magento coding standards](http://devdocs.magento.com/guides/v1.0/coding-standards/bk-coding-standards.html).
13+
1. Contributions must adhere to [Magento coding standards](http://devdocs.magento.com/guides/v2.0/coding-standards/bk-coding-standards.html).
1414
2. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances of a pull request to be merged quickly and without additional clarification requests.
1515
3. Commits must be accompanied by meaningful commit messages.
1616
4. PRs which include bug fixing, must be accompanied with step-by-step description of how to reproduce the bug.
@@ -25,7 +25,7 @@ The Magento 2 development team will review all issues and contributions submitte
2525
If you are a new GitHub user, we recommend that you create your own [free github account](https://github.com/signup/free). By doing that, you will be able to collaborate with the Magento 2 development team, “fork” the Magento 2 project and be able to easily send “pull requests”.
2626

2727
1. Search current [listed issues](https://github.com/magento/magento2/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
28-
2. Review the [Contributor License Agreement](https://github.com/magento/magento2/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT.html) if this is your first time contributing.
28+
2. Review the [Contributor License Agreement](https://magento.com/legaldocuments/mca) if this is your first time contributing.
2929
3. Create and test your work.
30-
4. Fork the Magento 2 repository according to [Fork a repository instructions](http://devdocs.magento.com/guides/v1.0/contributor-guide/CONTRIBUTING.html#fork) and when you are ready to send us a pull request – follow [Create a pull request instructions](http://devdocs.magento.com/guides/v1.0/contributor-guide/CONTRIBUTING.html#pull_request).
30+
4. Fork the Magento 2 repository according to [Fork a repository instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow [Create a pull request instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#pull_request).
3131
5. Once your contribution is received, Magento 2 development team will review the contribution and collaborate with you as needed to improve the quality of the contribution.

CONTRIBUTOR_LICENSE_AGREEMENT.html

Lines changed: 0 additions & 137 deletions
This file was deleted.

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Longtext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function render(\Magento\Framework\DataObject $row)
3030
$truncateLength = $this->getColumn()->getTruncate();
3131
}
3232
$text = $this->filterManager->truncate(parent::_getValue($row), ['length' => $truncateLength]);
33-
if ($this->getColumn()->getEscape()) {
33+
if (!$this->getColumn()->hasEscape() || $this->getColumn()->getEscape()) {
3434
$text = $this->escapeHtml($text);
3535
}
3636
if ($this->getColumn()->getNl2br()) {

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,18 @@ public function execute()
9898
return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
9999
}
100100

101-
$refreshTree = false;
102101
$data['general'] = $this->getRequest()->getPostValue();
102+
$isNewCategory = !isset($data['general']['entity_id']);
103103
$data = $this->stringToBoolConverting($this->stringToBoolInputs, $data);
104104
$data = $this->imagePreprocessing($data);
105105
$storeId = isset($data['general']['store_id']) ? $data['general']['store_id'] : null;
106-
if ($data) {
106+
$parentId = isset($data['general']['parent']) ? $data['general']['parent'] : null;
107+
if ($data['general']) {
107108
$category->addData($this->_filterCategoryPostData($data['general']));
108-
if (!$category->getId()) {
109-
$parentId = isset($data['general']['parent']) ? $data['general']['parent'] : null;
110-
if (!$parentId) {
111-
if ($storeId) {
112-
$parentId = $this->_objectManager->get(
113-
'Magento\Store\Model\StoreManagerInterface'
114-
)->getStore(
115-
$storeId
116-
)->getRootCategoryId();
117-
} else {
118-
$parentId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
119-
}
120-
}
121-
$parentCategory = $this->_objectManager->create('Magento\Catalog\Model\Category')->load($parentId);
109+
if ($isNewCategory) {
110+
$parentCategory = $this->getParentCategory($parentId, $storeId);
122111
$category->setPath($parentCategory->getPath());
123-
$category->setParentId($parentId);
112+
$category->setParentId($parentCategory->getId());
124113
}
125114

126115
/**
@@ -193,15 +182,21 @@ public function execute()
193182

194183
$category->save();
195184
$this->messageManager->addSuccess(__('You saved the category.'));
196-
$refreshTree = true;
185+
} catch (\Magento\Framework\Exception\AlreadyExistsException $e) {
186+
$this->messageManager->addError($e->getMessage());
187+
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
188+
$this->_getSession()->setCategoryData($data);
197189
} catch (\Exception $e) {
198190
$this->messageManager->addError(__('Something went wrong while saving the category.'));
199191
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
200192
$this->_getSession()->setCategoryData($data);
201-
$refreshTree = false;
202193
}
203194
}
204195

196+
$hasError = (bool)$this->messageManager->getMessages()->getCountByType(
197+
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
198+
);
199+
205200
if ($this->getRequest()->getPost('return_session_messages_only')) {
206201
$category->load($category->getId());
207202
// to obtain truncated category name
@@ -214,23 +209,17 @@ public function execute()
214209
return $resultJson->setData(
215210
[
216211
'messages' => $block->getGroupedHtml(),
217-
'error' => !$refreshTree,
212+
'error' => $hasError,
218213
'category' => $category->toArray(),
219214
]
220215
);
221216
}
222217

223-
$redirectParams = [
224-
'_current' => true,
225-
'id' => $category->getId()
226-
];
227-
if ($storeId) {
228-
$redirectParams['store'] = $storeId;
229-
}
218+
$redirectParams = $this->getRedirectParams($isNewCategory, $hasError, $category->getId(), $parentId, $storeId);
230219

231220
return $resultRedirect->setPath(
232-
'catalog/*/edit',
233-
$redirectParams
221+
$redirectParams['path'],
222+
$redirectParams['params']
234223
);
235224
}
236225

@@ -283,4 +272,56 @@ public function stringToBoolConverting($stringToBoolInputs, $data)
283272
}
284273
return $data;
285274
}
275+
276+
/**
277+
* Get parent category
278+
*
279+
* @param int $parentId
280+
* @param int $storeId
281+
*
282+
* @return \Magento\Catalog\Model\Category
283+
*/
284+
protected function getParentCategory($parentId, $storeId)
285+
{
286+
if (!$parentId) {
287+
if ($storeId) {
288+
$parentId = $this->_objectManager->get(
289+
\Magento\Store\Model\StoreManagerInterface::class
290+
)->getStore(
291+
$storeId
292+
)->getRootCategoryId();
293+
} else {
294+
$parentId = \Magento\Catalog\Model\Category::TREE_ROOT_ID;
295+
}
296+
}
297+
return $this->_objectManager->create(\Magento\Catalog\Model\Category::class)->load($parentId);
298+
}
299+
300+
/**
301+
* Get category redirect path
302+
*
303+
* @param bool $isNewCategory
304+
* @param bool $hasError
305+
* @param int $categoryId
306+
* @param int $parentId
307+
* @param int $storeId
308+
*
309+
* @return array
310+
*/
311+
protected function getRedirectParams($isNewCategory, $hasError, $categoryId, $parentId, $storeId)
312+
{
313+
$params = ['_current' => true];
314+
if ($storeId) {
315+
$params['store'] = $storeId;
316+
}
317+
if ($isNewCategory && $hasError) {
318+
$path = 'catalog/*/add';
319+
$params['parent'] = $parentId;
320+
} else {
321+
$path = 'catalog/*/edit';
322+
$params['id'] = $categoryId;
323+
324+
}
325+
return ['path' => $path, 'params' => $params];
326+
}
286327
}

app/code/Magento/Catalog/Model/Category.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ public function move($parentId, $afterCategoryId)
442442
if (!$productIndexer->isScheduled()) {
443443
$productIndexer->reindexList(array_merge($this->getPathIds(), $oldParentIds));
444444
}
445+
$this->_eventManager->dispatch('clean_cache_by_tags', ['object' => $this]);
445446
$this->_cacheManager->clean([self::CACHE_TAG]);
446447

447448
return $this;

0 commit comments

Comments
 (0)