Skip to content

Commit 84e5178

Browse files
author
Bibu Mathew
committed
MAGETWO-30809: Compiled definitions can cause unexpected errors compared to runtime definitions
- Updated getParemeters method to use reflection if the definition is not found in compiled files
1 parent 1be6ca1 commit 84e5178

File tree

1 file changed

+12
-1
lines changed
  • lib/internal/Magento/Framework/ObjectManager/Definition

1 file changed

+12
-1
lines changed

lib/internal/Magento/Framework/ObjectManager/Definition/Compiled.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ abstract class Compiled implements \Magento\Framework\ObjectManager\DefinitionIn
1616
*/
1717
protected $_definitions;
1818

19+
/**
20+
* @var \Magento\Framework\Code\Reader\ClassReader
21+
*/
22+
protected $reader ;
23+
1924
/**
2025
* @param array $definitions
2126
*/
22-
public function __construct(array $definitions)
27+
public function __construct(array $definitions, \Magento\Framework\Code\Reader\ClassReader $reader = null)
2328
{
2429
list($this->_signatures, $this->_definitions) = $definitions;
30+
$this->reader = $reader ?: new \Magento\Framework\Code\Reader\ClassReader();
2531
}
2632

2733
/**
@@ -50,6 +56,11 @@ abstract protected function _unpack($signature);
5056
*/
5157
public function getParameters($className)
5258
{
59+
// if the definition isn't found in the list gathered from the compiled file using reflection to find it
60+
if (!isset($this->_definitions[$className])) {
61+
return $this->reader->getConstructor($className);
62+
}
63+
5364
$definition = $this->_definitions[$className];
5465
if ($definition !== null) {
5566
if (is_string($this->_signatures[$definition])) {

0 commit comments

Comments
 (0)