PHP 7.2 release introduced many breaking changes that could prevent some of your application from working properly. Among the many backward-incompatible improvements, perhaps the most crippling one is what they called Warn when counting non-countable types.
Here’s what it does in a nutshell (from php.net official docs):
An E_WARNING will now be emitted when attempting to count() non-countable types (this includes the sizeof() alias function).
Warning: count(): Parameter must be an array or an object that implements Countable in %s on line %d
At a first glance this might seem trivial, but there’s a high chance that – if you see such warning – you’ll have to deal with some minor or major issues that could prevent your web app from working properly. If you own the code – or if you’re willing to perform the required chance to the third party code – you’ll be eventually able to fix that by yourself, but if you don’t want to (or cannot) do that, you should seriously consider downgrading your PHP to a more compatible release, such as PHP 7.1.
In order to do that, you have to perform the following commands – assuming you’re running a Linux CentOS 7.x machine with the Remi’s RPM repositories installed: if you don’t, read this post for further instructions. Before you do that, it can be wise to backup your /etc/php.ini file and – if we’re using the php-fpm FastCGI extension – the /etc/php-fpm.d/ folder.
- Open a terminal window.
- Identify the PHP packages you need to uninstall with the following command: rpm -qa |grep php .
- Take a note and/or make a screenshot of all the package you need – as you’ll have to reinstall them later on.
- Remove the installed PHP 7.2 packages – along with all their dependencies – with the following command: yum remove php-*
- Install the PHP 7.1 packages with the following command:
yum --disablerepo=remi-php72 --enablerepo=remi-php71 install php php-common php-gd php-xml php-fpm php-mysqlnd [...]
Once done, you just have to restore our previous setup in the following way:
- Restore your previous /etc/php.ini file from the backup you made;
- In case we’re using the php-fpm FastCGI extension, you also have to restore your previous /etc/php-fpm.d/ folder from the backup and type the following commands to start-enable the php-fpm service:
systemctl start php-fpm
systemctl enable php-fpm
Needless to say, you can use the same technique to roll-back to a previous version, such as PHP 7.0 or PHP 5.6: just be sure to use the --disablerepo parameter to exclude the newer PHP repositories as explained above.