Last Updated on September 21, 2023 EDT by Jordan
Table of Contents
Content Error or Suggest an Edit
Notice a grammatical error or technical inaccuracy? Let us know; we will give you credit!
Introduction
This article stems from Kinsta’s move to disable the creation of new sites on PHP 7.4 starting on November 29th 2022. Here’s the screenshot from the Self Managed WordPress GridPane Facebook Group.
Checking PHP Compatibility using PHP Code Sniffer
There is a free tool out there called PHP Code Sniffer that can check PHP code’s compatibility with specific versions of PHP.
Here’s a link to the Github repository https://github.com/squizlabs/PHP_CodeSniffer which provides more information on the tool.
Downloading PHP Code Sniffer
You can download PHP Code Sniffer’s latest release on their release page. https://github.com/squizlabs/PHP_CodeSniffer/releases
You will want to download the phpcs.phar file into a Linux shell with the PHP cli binary or package available. This can be on your live site via SSH or using WSL or Terminal on macOS as long as the php binary is available. You can run the phpcs.phar command and target a single file or a whole directory.
cd ~/ mkdir tmp cd tmp wget https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.1/phpcs.phar
Downloading the PHP Compatibility Coding Standard for PHP CodeSniffer
There is one more step, you will need the PHP Compatibility Coding Standard library for PHP Code Sniffer. You can download this from the Github repository at https://github.com/PHPCompatibility/PHPCompatibility
As with PHP Code Sniffer, you will need to download the latest release file. It’s a zip file and you will need to extract it to a directory. You can place this anywhere, but you will need to know the full path so we can tell PHP Code Sniffer where to find it.
Visit the releases page at https://github.com/PHPCompatibility/PHPCompatibility/releases copy the link to the latest release file and use wget to pull it down, and then extract it.
cd ~/tmp wget https://github.com/PHPCompatibility/PHPCompatibility/archive/refs/tags/9.3.5.zip unzip 9.3.5.zip
The above commands will extract the PHP Compatibility library to ~/tmp/PHPCompatibility-9.3.5
and we now need to tell PHP Code Sniffer where this is located.
~/tmp/phpcs.phar --config-set installed_paths ~/tmp/PHPCompatibility-9.3.5
Running PHP Code Sniffer Against a WordPress Plugin
Here is an example of running compatibility for PHP 8.0 against the fluent-smtp plugin
./phpcs.phar -p htdocs/wp-content/plugins/fluent-smtp βstandard=PHPCompatibility βruntime-set testVersion 8.0 -n
You should now receive the following output.
β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦ 60 / 429 (14%) β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦ 120 / 429 (28%) β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦ 180 / 429 (42%) β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦.EEβ¦β¦β¦β¦β¦ 240 / 429 (56%) β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦ 300 / 429 (70%) β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦SSβ¦S.SSSβ¦β¦β¦β¦β¦.. 360 / 429 (84%) β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦β¦ 420 / 429 (98%) β¦β¦β¦ 429 / 429 (100%) FILE: htdocs/wp-content/plugins/fluent-smtp/includes/libs/google-api-client/vendor/phpseclib/phpseclib/phpseclib/Crypt/Base.php βββββββββββββββββββββββββββββββββββββββββββββββββββ FOUND 44 ERRORS AFFECTING 24 LINES βββββββββββββββββββββββββββββββββββββββββββββββββββ 777 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 777 | ERROR | Function mcrypt_generic_init() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 810 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 810 | ERROR | Function mcrypt_generic_init() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 813 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 813 | ERROR | Function mcrypt_generic() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 818 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 818 | ERROR | Function mcrypt_generic() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 827 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 827 | ERROR | Function mcrypt_generic() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 837 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 837 | ERROR | Function mcrypt_generic() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 840 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 840 | ERROR | Function mcrypt_generic_init() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1089 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1089 | ERROR | Function mcrypt_generic_init() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1117 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1117 | ERROR | Function mcrypt_generic() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1122 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1122 | ERROR | Function mcrypt_generic() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1131 | ERROR | Function mdecrypt_generic() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1134 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1134 | ERROR | Function mcrypt_generic_init() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1596 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1596 | ERROR | Function mcrypt_list_algorithms() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1675 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1675 | ERROR | Function mcrypt_module_close() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1676 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1676 | ERROR | Function mcrypt_module_close() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1681 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1681 | ERROR | Function mcrypt_module_close() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1788 | ERROR | The constant βMCRYPT_MODE_ECBβ is deprecated since PHP 7.1 and removed since PHP 7.2 1789 | ERROR | The constant βMCRYPT_MODE_CBCβ is deprecated since PHP 7.1 and removed since PHP 7.2 1791 | ERROR | The constant βMCRYPT_MODE_NOFBβ is deprecated since PHP 7.1 and removed since PHP 7.2 1792 | ERROR | The constant βMCRYPT_MODE_STREAMβ is deprecated since PHP 7.1 and removed since PHP 7.2 1795 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1795 | ERROR | Function mcrypt_module_open() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1796 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1796 | ERROR | Function mcrypt_module_open() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1802 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1802 | ERROR | Function mcrypt_module_open() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead 1802 | ERROR | The constant βMCRYPT_MODE_ECBβ is deprecated since PHP 7.1 and removed since PHP 7.2 1807 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 1807 | ERROR | Function mcrypt_generic_init() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead βββββββββββββββββββββββββββββββββββββββββββββββββββ FILE: /htdocs/wp-content/plugins/fluent-smtp/includes/libs/google-api-client/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php ββββββββββββββββββββββββββββββββββββββββββββββββββ- FOUND 5 ERRORS AFFECTING 2 LINES ββββββββββββββββββββββββββββββββββββββββββββββββββ- 69 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 69 | ERROR | Function mcrypt_create_iv() is deprecated since PHP 7.1 and removed since PHP 7.2; Use random_bytes() or OpenSSL instead 108 | ERROR | Extension βmcryptβ is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead 108 | ERROR | Function mcrypt_create_iv() is deprecated since PHP 7.1 and removed since PHP 7.2; Use random_bytes() or OpenSSL instead 108 | ERROR | The constant βMCRYPT_DEV_URANDOMβ is deprecated since PHP 7.1 and removed since PHP 7.2 ββββββββββββββββββββββββββββββββββββββββββββββββββ-
Viola, you’ve just found the Fluent SMTP plugin has a library called google-api-client that has incompatible PHP 8.0 code.
Running PHP Code Sniffer Against All Plugins
If you want to run PHP Code Sniffer against all your plugins, simply change the directory path
./phpcs.phar -p htdocs/wp-content/plugins βstandard=PHPCompatibility βruntime-set testVersion 8.0 -n
This will produce a report of all your affecting plugins, it might be large.
WordPress Plugins not compatible with PHP 8.0
The following are plugins not compatible with PHP 8.0, if you’ve notified an author of this, please let us know with a link to the support thread and we will post it in the table below.
Changelog
- 09-22-2022 – Added section “Running PHP Code Sniffer Against All Plugins
Last Updated on September 21, 2023 EDT by Jordan