Closed
Description
Preconditions
- Magento 2.1 Enterprise (https://github.com/magento/magento2/releases/tag/2.1.0)
- Dev Environment - PHP 7.0.8, MySQL 5.6.10
- Production Environment (Staging/Dev) - PHP 7.08, MySQL 5.6.28
Steps to reproduce
- Create a module extending the class
Magento\Framework\View\Element\Html\Links
- Add the following construct.
public function __construct(Context $context, Session $session)
{
$this->session = $session;
parent::__construct($context);
}
Where the types are defined at the top of the file as:
use Magento\Framework\View\Element\Html\Links as MagentoLinks;
use Magento\Customer\Model\Session;
use Magento\Framework\View\Element\Template\Context;
- Run
di:compile
. - Confirm the result is as follows:
php bin/magento setup:di:compile
Compilation was started.
Interception cache generation... 7/7 [============================] 100% 6 mins 318.0 MiBB0 MiB
Generated code and dependency injection configuration successfully.
- Load up a template with a Block type from your newly created Links class that extends the magento version in your browser.
- The following error is displayed:
Fatal error: Uncaught TypeError: Argument 1 passed to ModName\Framework\View\Element\Html\Links::__construct() must be an instance of Magento\Framework\View\Element\Template\Context, instance of Magento\Framework\ObjectManager\ObjectManager given, called in /domains/***.com/___deploy/releases/20160728154029/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 93 and defined in /domains/***.com/___deploy/releases/20160728154029/app/code/ModName/Framework/View/Element/Html/Links.php:20 Stack trace: #0 /domains/***.com/___deploy/releases/20160728154029/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): ModName\Framework\View\Element\Html\Links->__construct(Object(Magento\Framework\ObjectManager\ObjectManager)) #1 /domains/***.com/___deploy/releases/20160728154029/vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('ModName in /domains/***.com/___deploy/releases/20160728154029/app/code/ModName/Framework/View/Element/Html/Links.php on line 20
I have a attached a screenshot of the arguments being passed into the create function for Magento\Framework\ObjectManager\Factory\Compiled
.
Expected result
- The template file should load without an issue. It does before you use the compiler.
Actual result
- The frontend of Magento will error with the above message.
Delete the var/di directory and the file works fine, recompile again and it breaks. This happens on a local dev environment, and a production dev/staging environment.