So I wanted to try out Magento 2 on php 7.1 (I use ubuntu 16 xenial). Everything seems to be working — I ran into one issue with the mcrypt functionality being deprecated in php 7.1 On every page load I was receiving:
Function mcyrpt_module_open() is deprecated
Looking on github, it seems Magento is aware of this and mcrypt support will be removed in 2.2 (or maybe even 2.1.2).
However, if you’re like me (and you don’t want to wait) there is just one file that you need to patch. (I tried disabling the DEPRECATED warnings, however in developer mode it seems that Magento re-enables these).
The file in question is vendor/magento/framework/Encryption/Crypt.php. You need to go through the file and add the @ sign before any of the mcrypt calls (this instructs the php interpreter to suppress warnings generated from these lines).
For example:
$this->_handle = mcrypt_module_open($cipher, '', $mode, '');
Becomes
$this->_handle = @mcrypt_module_open($cipher, '', $mode, '');
Pretty simple! If you don’t want to patch it by hand, download the modified version of the file here.
Very usefull
It is now Version 2.1.6 and still an issue. Magento needs to get default support for 7.1 working soon. They really cannot expect us not to keep our systems up-to-date?
thanks for your help,i just facing this problem
Thanks, you save my time 🙂
Thank’s. Your post is very useful.
thank you very much, this is very helpful..
Any idea how i can bypass the installation check for mcrypt extension?
thanks, problem solved.
Thanks, you are my saver)
Awesome , thanks
Yeah, useful fix! Thank you
Thanks for the solution. Even for decrypt, seems like we have to prefix the @ suppressor.
Very helpful thanks. When will the commands catch up with PHP versions though?
Thank You 🙂
A life saver! and i appreciate the explanation.