Skip to content

Commit 92b03ef

Browse files
committed
MAGETWO-56063: After upgrading from 2.0.7 to 2.1, editing a category gives a 500 error
- fixed logger injection
1 parent 2f84b68 commit 92b03ef

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

app/code/Magento/Eav/Model/ResourceModel/ReadHandler.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\Model\Entity\ScopeInterface;
1515
use Magento\Framework\EntityManager\Operation\AttributeInterface;
1616
use Magento\Eav\Model\Entity\AttributeCache;
17+
use Psr\Log\LoggerInterface;
1718

1819
/**
1920
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -51,7 +52,7 @@ class ReadHandler implements AttributeInterface
5152
protected $scopeResolver;
5253

5354
/**
54-
* @var \Psr\Log\LoggerInterface
55+
* @var LoggerInterface
5556
*/
5657
private $logger;
5758

@@ -64,21 +65,24 @@ class ReadHandler implements AttributeInterface
6465
* @param AppResource $appResource
6566
* @param ScopeResolver $scopeResolver
6667
* @param AttributeCache $attributeCache
68+
* @param LoggerInterface $logger
6769
*/
6870
public function __construct(
6971
AttributeRepository $attributeRepository,
7072
MetadataPool $metadataPool,
7173
SearchCriteriaBuilder $searchCriteriaBuilder,
7274
AppResource $appResource,
7375
ScopeResolver $scopeResolver,
74-
AttributeCache $attributeCache
76+
AttributeCache $attributeCache,
77+
LoggerInterface $logger
7578
) {
7679
$this->attributeRepository = $attributeRepository;
7780
$this->metadataPool = $metadataPool;
7881
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
7982
$this->appResource = $appResource;
8083
$this->scopeResolver = $scopeResolver;
8184
$this->attributeCache = $attributeCache;
85+
$this->logger = $logger;
8286
}
8387

8488
/**
@@ -172,7 +176,7 @@ public function execute($entityType, $entityData, $arguments = [])
172176
if (isset($attributesMap[$attributeValue['attribute_id']])) {
173177
$entityData[$attributesMap[$attributeValue['attribute_id']]] = $attributeValue['value'];
174178
} else {
175-
$this->getLogger()->warning(
179+
$this->logger->warning(
176180
"Attempt to load value of nonexistent EAV attribute '{$attributeValue['attribute_id']}'
177181
for entity type '$entityType'."
178182
);
@@ -181,18 +185,4 @@ public function execute($entityType, $entityData, $arguments = [])
181185
}
182186
return $entityData;
183187
}
184-
185-
/**
186-
* Get logger
187-
*
188-
* @return \Psr\Log\LoggerInterface
189-
* @deprecated
190-
*/
191-
private function getLogger()
192-
{
193-
if ($this->logger == null) {
194-
$this->logger = ObjectManager::getInstance()->get(\Psr\Log\LoggerInterface::class);
195-
}
196-
return $this->logger;
197-
}
198188
}

0 commit comments

Comments
 (0)