719-286-0751 info@cadence-labs.com

Magento 2 & Php 7.1 Fix: Function mcyrpt_module_open() is deprecated

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.

 

Alan Barber is the Lead Web Developer at Cadence Labs and a Magento Certified developer.

13 Comments

  1. teser

    Very usefull

    Reply
  2. David Ford

    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?

    Reply
  3. Frank

    thanks for your help,i just facing this problem

    Reply
  4. Devendra

    Thanks, you save my time 🙂

    Reply
  5. Guest

    Thank’s. Your post is very useful.

    Reply
  6. Gustavo

    Any idea how i can bypass the installation check for mcrypt extension?

    Reply
  7. ferhat

    thanks, problem solved.

    Reply
  8. Love

    Thanks, you are my saver)

    Reply
  9. vaibhav

    Awesome , thanks

    Reply
  10. Poh

    Yeah, useful fix! Thank you

    Reply
  11. Kuldeep Singh

    Thanks for the solution. Even for decrypt, seems like we have to prefix the @ suppressor.

    Reply
  12. Dan Atrill

    Very helpful thanks. When will the commands catch up with PHP versions though?

    Reply

Trackbacks/Pingbacks

  1. PHP 7.1 is finally available – migrate now! » Combell blog - […] Only those who use the Magento e-commerce software should be careful. If you want to have Magento run with…

Submit a Comment

Your email address will not be published. Required fields are marked *

Install our webapp on your iPhone! Tap and then Add to homescreen.
Share This