Skip to content

Commit b30c10a

Browse files
committed
Merge remote-tracking branch 'origin/2.1.8-develop' into MAGETWO-58533
# Conflicts: # dev/tests/integration/testsuite/Magento/Security/Model/AdminSessionsManagerTest.php # dev/tests/integration/testsuite/Magento/Security/Model/Plugin/AuthSessionTest.php
2 parents 7613fac + 658e754 commit b30c10a

File tree

110 files changed

+8002
-1011
lines changed

Some content is hidden

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

110 files changed

+8002
-1011
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ If you are a new GitHub user, we recommend that you create your own [free github
2929
3. Create and test your work.
3030
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.
32+
33+
## Code of Conduct
34+
35+
Please note that this project is released with a Contributor Code of Conduct. We expect you to agree to its terms when participating in this project.
36+
The full text is available in the repository [Wiki](https://github.com/magento/magento2/wiki/Magento-Code-of-Conduct).

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ abstract class Category extends \Magento\Backend\App\Action
3131
*/
3232
protected function _initCategory($getRootInstead = false)
3333
{
34-
$categoryId = (int)$this->getRequest()->getParam('id', false);
34+
$categoryId = $this->resolveCategoryId();
3535
$storeId = (int)$this->getRequest()->getParam('store');
36-
$category = $this->_objectManager->create('Magento\Catalog\Model\Category');
36+
$category = $this->_objectManager->create(\Magento\Catalog\Model\Category::class);
3737
$category->setStoreId($storeId);
3838

3939
if ($categoryId) {
4040
$category->load($categoryId);
4141
if ($storeId) {
4242
$rootId = $this->_objectManager->get(
43-
'Magento\Store\Model\StoreManagerInterface'
43+
\Magento\Store\Model\StoreManagerInterface::class
4444
)->getStore(
4545
$storeId
4646
)->getRootCategoryId();
@@ -55,13 +55,25 @@ protected function _initCategory($getRootInstead = false)
5555
}
5656
}
5757

58-
$this->_objectManager->get('Magento\Framework\Registry')->register('category', $category);
59-
$this->_objectManager->get('Magento\Framework\Registry')->register('current_category', $category);
60-
$this->_objectManager->get('Magento\Cms\Model\Wysiwyg\Config')
58+
$this->_objectManager->get(\Magento\Framework\Registry::class)->register('category', $category);
59+
$this->_objectManager->get(\Magento\Framework\Registry::class)->register('current_category', $category);
60+
$this->_objectManager->get(\Magento\Cms\Model\Wysiwyg\Config::class)
6161
->setStoreId($this->getRequest()->getParam('store'));
6262
return $category;
6363
}
6464

65+
/**
66+
* Resolve Category Id (from get or from post).
67+
*
68+
* @return int
69+
*/
70+
private function resolveCategoryId()
71+
{
72+
$categoryId = (int)$this->getRequest()->getParam('id', false);
73+
74+
return $categoryId ?: (int)$this->getRequest()->getParam('entity_id', false);
75+
}
76+
6577
/**
6678
* Build response for ajax request
6779
*
@@ -79,7 +91,7 @@ protected function ajaxRequestResponse($category, $resultPage)
7991
if (empty($breadcrumbsPath)) {
8092
// but if no category, and it is deleted - prepare breadcrumbs from path, saved in session
8193
$breadcrumbsPath = $this->_objectManager->get(
82-
'Magento\Backend\Model\Auth\Session'
94+
\Magento\Backend\Model\Auth\Session::class
8395
)->getDeletedPath(
8496
true
8597
);
@@ -107,7 +119,7 @@ protected function ajaxRequestResponse($category, $resultPage)
107119
['response' => $eventResponse, 'controller' => $this]
108120
);
109121
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
110-
$resultJson = $this->_objectManager->get('Magento\Framework\Controller\Result\Json');
122+
$resultJson = $this->_objectManager->get(\Magento\Framework\Controller\Result\Json::class);
111123
$resultJson->setHeader('Content-type', 'application/json', true);
112124
$resultJson->setData($eventResponse->getData());
113125
return $resultJson;

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

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class Category extends AbstractResource
3333
*/
3434
protected $_categoryProductTable;
3535

36+
/**
37+
* Entities where attribute is filled.
38+
*
39+
* @var array[]
40+
*/
41+
private $entitiesWhereAttributesIs;
42+
3643
/**
3744
* Id of 'is_active' category attribute
3845
*
@@ -575,22 +582,29 @@ public function getIsActiveAttributeId()
575582
*/
576583
public function findWhereAttributeIs($entityIdsFilter, $attribute, $expectedValue)
577584
{
578-
$linkField = $this->getLinkField();
579-
$bind = ['attribute_id' => $attribute->getId(), 'value' => $expectedValue];
580-
$selectEntities = $this->getConnection()->select()->from(
581-
['ce' => $this->getTable('catalog_category_entity')],
582-
['entity_id']
583-
)->joinLeft(
584-
['ci' => $attribute->getBackend()->getTable()],
585-
"ci.{$linkField} = ce.{$linkField} AND attribute_id = :attribute_id",
586-
['value']
587-
)->where(
588-
'ci.value = :value'
589-
)->where(
590-
'ce.entity_id IN (?)',
591-
$entityIdsFilter
592-
);
593-
return $this->getConnection()->fetchCol($selectEntities, $bind);
585+
$entityIdsFilterHash = md5(serialize($entityIdsFilter));
586+
587+
if (!isset($this->entitiesWhereAttributesIs[$entityIdsFilterHash][$attribute->getId()][$expectedValue])) {
588+
$linkField = $this->getLinkField();
589+
$bind = ['attribute_id' => $attribute->getId(), 'value' => $expectedValue];
590+
$selectEntities = $this->getConnection()->select()->from(
591+
['ce' => $this->getTable('catalog_category_entity')],
592+
['entity_id']
593+
)->joinLeft(
594+
['ci' => $attribute->getBackend()->getTable()],
595+
"ci.{$linkField} = ce.{$linkField} AND attribute_id = :attribute_id",
596+
['value']
597+
)->where(
598+
'ci.value = :value'
599+
)->where(
600+
'ce.entity_id IN (?)',
601+
$entityIdsFilter
602+
);
603+
$this->entitiesWhereAttributesIs[$entityIdsFilterHash][$attribute->getId()][$expectedValue] =
604+
$this->getConnection()->fetchCol($selectEntities, $bind);
605+
}
606+
607+
return $this->entitiesWhereAttributesIs[$entityIdsFilterHash][$attribute->getId()][$expectedValue];
594608
}
595609

596610
/**
@@ -1035,7 +1049,7 @@ private function getEntityManager()
10351049
{
10361050
if (null === $this->entityManager) {
10371051
$this->entityManager = \Magento\Framework\App\ObjectManager::getInstance()
1038-
->get('Magento\Framework\EntityManager\EntityManager');
1052+
->get(\Magento\Framework\EntityManager\EntityManager::class);
10391053
}
10401054
return $this->entityManager;
10411055
}
@@ -1047,7 +1061,7 @@ private function getAggregateCount()
10471061
{
10481062
if (null === $this->aggregateCount) {
10491063
$this->aggregateCount = \Magento\Framework\App\ObjectManager::getInstance()
1050-
->get('Magento\Catalog\Model\ResourceModel\Category\AggregateCount');
1064+
->get(\Magento\Catalog\Model\ResourceModel\Category\AggregateCount::class);
10511065
}
10521066
return $this->aggregateCount;
10531067
}

0 commit comments

Comments
 (0)