Magento 1 official PHP 7.2 patches

You probably noticed that Magento PHP 7.2 support patches are available for download HERE (Magento Open Source version).

For Magento Commerce customers, you should find the patches under Magento Commerce 1.x > Support Patches and Security Patches > PHP Compatibility patches in the Downloads section of your account.

We at Inchoo worked on this contribution, so we decided to share a few more words about it, especially because we noticed that Magento released patches in somewhat different format than usual.

History

Stjepan Udovičić and Tomas Novoselić started to work on those patches with Piotr Kaminski in May 2018.

Big part of the current batch of patches is based on the original Inchoo’s PHP7 extension currently maintained by Ivan Weiler.

A big thank-you also goes to all GitHub contributors to our original extension.

Instructions

Patches are available for:

  • Magento Open Source (Community) releases 1.9.2.x up to Magento 1.9.3.x
  • Magento Commerce (Enterprise) releases 1.14.2.x up to 1.14.3.x

Once you find the patches, you might be surprised by their filenames, but there is nothing to be afraid of.

Those are just regular *.patch files that you can apply on your system using patch or GIT.

So, once you download appropriate patch version, put it in your website root directory and execute the following command in your website root:

patch -p1 < PATCH-1.9.3.1-1.9.3.9_PHP7-2018-09-13-08-01-43.2_v2

You should get the output looking like this:

tomas ~/var/docker/m1.docker/html $ patch -p1 < PATCH-1.9.3.1-1.9.3.9_PHP7-2018-09-13-08-01-43.2_v2
patching file app/Mage.php
patching file app/code/core/Mage/Core/Helper/Data.php
patching file app/code/core/Mage/Core/Model/Resource/Session.php
patching file app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
patching file app/code/core/Mage/Core/functions.php
patching file app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Group.php
patching file app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Store.php
patching file app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Website.php
patching file app/code/core/Mage/Customer/Model/Entity/Address/Attribute/Source/Country.php
patching file app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Country.php
patching file app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Region.php
patching file app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Store.php
patching file app/code/core/Mage/Install/etc/install.xml
patching file app/code/core/Mage/Sales/etc/config.xml
patching file app/code/core/Mage/Shipping/Model/Carrier/Abstract.php
patching file app/code/core/Mage/Wishlist/Model/Observer.php
patching file lib/Varien/Autoload.php
patching file lib/Varien/File/Uploader.php
patching file lib/Varien/Io/Sftp.php
patching file lib/mcrypt_compat/mcrypt.php
patching file lib/phpseclib/Crypt/AES.php
patching file lib/phpseclib/Crypt/Base.php
patching file lib/phpseclib/Crypt/Blowfish.php
patching file lib/phpseclib/Crypt/DES.php
patching file lib/phpseclib/Crypt/Hash.php
patching file lib/phpseclib/Crypt/RC2.php
patching file lib/phpseclib/Crypt/RC4.php
patching file lib/phpseclib/Crypt/RSA.php
patching file lib/phpseclib/Crypt/Random.php
patching file lib/phpseclib/Crypt/Rijndael.php
patching file lib/phpseclib/Crypt/TripleDES.php
patching file lib/phpseclib/Crypt/Twofish.php
patching file lib/phpseclib/File/ANSI.php
patching file lib/phpseclib/File/ASN1.php
patching file lib/phpseclib/File/ASN1/Element.php
patching file lib/phpseclib/File/X509.php
patching file lib/phpseclib/Math/BigInteger.php
patching file lib/phpseclib/Net/SCP.php
patching file lib/phpseclib/Net/SFTP.php
patching file lib/phpseclib/Net/SFTP/Stream.php
patching file lib/phpseclib/Net/SSH1.php
patching file lib/phpseclib/Net/SSH2.php
patching file lib/phpseclib/PHP/Compat/Function/array_fill.php
patching file lib/phpseclib/PHP/Compat/Function/bcpowmod.php
patching file lib/phpseclib/PHP/Compat/Function/str_split.php
patching file lib/phpseclib/System/SSH/Agent.php
patching file lib/phpseclib/System/SSH/Agent/Identity.php
patching file lib/phpseclib/bootstrap.php
patching file lib/phpseclib/openssl.cnf

If you prefer GIT over Patch for any reason, you can do the following:

git apply PATCH-1.9.3.1-1.9.3.9_PHP7-2018-09-13-08-01-43.2_v2

After which you can expect something like this:

tomas ~/var/docker/m1.docker/html $ git status
On branch master
Your branch is up to date with 'origin/master'.
 
Changes not staged for commit:
(use "git add/rm ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
 
modified: app/Mage.php
modified: app/code/core/Mage/Core/Helper/Data.php
modified: app/code/core/Mage/Core/Model/Resource/Session.php
modified: app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
modified: app/code/core/Mage/Core/functions.php
modified: app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Group.php
modified: app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Store.php
modified: app/code/core/Mage/Customer/Model/Customer/Attribute/Source/Website.php
modified: app/code/core/Mage/Customer/Model/Entity/Address/Attribute/Source/Country.php
modified: app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Country.php
modified: app/code/core/Mage/Customer/Model/Resource/Address/Attribute/Source/Region.php
modified: app/code/core/Mage/Eav/Model/Entity/Attribute/Source/Store.php
modified: app/code/core/Mage/Install/etc/install.xml
modified: app/code/core/Mage/Sales/etc/config.xml
modified: app/code/core/Mage/Shipping/Model/Carrier/Abstract.php
modified: app/code/core/Mage/Wishlist/Model/Observer.php
modified: lib/Varien/Autoload.php
modified: lib/Varien/File/Uploader.php
modified: lib/Varien/Io/Sftp.php
modified: lib/phpseclib/Crypt/AES.php
modified: lib/phpseclib/Crypt/DES.php
modified: lib/phpseclib/Crypt/Hash.php
modified: lib/phpseclib/Crypt/RC4.php
modified: lib/phpseclib/Crypt/RSA.php
modified: lib/phpseclib/Crypt/Random.php
modified: lib/phpseclib/Crypt/Rijndael.php
modified: lib/phpseclib/Crypt/TripleDES.php
modified: lib/phpseclib/Math/BigInteger.php
modified: lib/phpseclib/Net/SFTP.php
modified: lib/phpseclib/Net/SSH1.php
modified: lib/phpseclib/Net/SSH2.php
deleted: lib/phpseclib/PHP/Compat/Function/array_fill.php
deleted: lib/phpseclib/PHP/Compat/Function/bcpowmod.php
deleted: lib/phpseclib/PHP/Compat/Function/str_split.php
 
Untracked files:
(use "git add ..." to include in what will be committed)
 
PATCH-1.9.3.1-1.9.3.9_PHP7-2018-09-13-08-01-43.2_v2
lib/mcrypt_compat/
lib/phpseclib/Crypt/Base.php
lib/phpseclib/Crypt/Blowfish.php
lib/phpseclib/Crypt/RC2.php
lib/phpseclib/Crypt/Twofish.php
lib/phpseclib/File/
lib/phpseclib/Net/SCP.php
lib/phpseclib/Net/SFTP/
lib/phpseclib/System/
lib/phpseclib/bootstrap.php
lib/phpseclib/openssl.cnf
 
no changes added to commit (use "git add" and/or "git commit -a")

Just in case…

1) Keep in mind that even after you patch your site, it will still be compatible with the PHP version you used before applying this patch.

2) Note that your site needs to meet requirements regarding SUPEE_* patches listed next to each specific version supported by PHP 7.2 patch.

3) Make sure that you have uninstalled Inchoo’s original PHP7 compatibility patch https://github.com/Inchoo/Inchoo_PHP7 in case you were using it before applying these patches. (note that it has files in app/code/local/Mage or app/code/community/Mage depending on which version you are using)

4) Check if you have any 3rd party extensions that are incompatible with PHP 7 using this regex against local and community directories:

->$.+[.+](.*)

5) Make sure that you test this on your setup just as precaution to avoid issues with third party extensions etc.

And finally… it is great seeing our own contribution make its way to the official product!

Thanks, Magento, for reaching out to us to make these patches available for everyone!