Changes in newer versions of PHP have led to more warnings being issued about code that isn’t correctly written for more recent versions of PHP. This is a more prominent issue for Zen Cart websites, since it can lead to the “logs” directory quickly filling with many files. That is something we have been dealing with quite a bit recently while working on upgrades of Zen Cart, which often coincides with switching to a newer version of PHP.
Making the situation more complicated is that the directory can also contain messages about errors, in which an issue with the website caused it to not function, alongside all those warnings of things that don’t currently cause the website to not function.
While changing back to the older version of PHP would stop those files from being created, if you are changing back to PHP version that isn’t supported anymore, you are reintroducing security risk. Though we should note, it has been quite a long time since a security issue in PHP was a major source of hacking.
More permanently dealing with the warning log files involves addressing what is being warned about. That starts with making sure you are using a version of Zen Cart that is compatible with the PHP version in use. From there, updating other software on the website may resolve issues, if the newer version has had changes made related to those. Once that has been done, that leaves you with other third-party code that needs to be updated. Those with some familiarity with PHP code or coding in general can probably handle making those changes. Others will probably want to find someone to handle that for them. With much of what needs to be dealt with, a prior familiarity with Zen Cart isn’t necessary.
While some of the issues we have run across are more complicated, most of the issue that need to be addressed are easy to fix. Take one common issue in our experience, usage of PHP 4 style constructors. The log files will provide a warning like this for that:
PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; rialto_export has a deprecated constructor in /home/[redacted]/public_html/includes/classes/observers/class.rialto_export.php on line 9.
Opening the file listed shows that class rialto_export has a constructor of the same name:
9 10 11 12 | class rialto_export extends base { var $client, $web_username, $web_password, $success_message = false, $error_message = false; function rialto_export() { |
That can be resolved by renaming the function to “__construct()” like this:
9 10 11 12 | class rialto_export extends base { var $client, $web_username, $web_password, $success_message = false, $error_message = false; function __construct() { |
For most issues, doing an internet search on the warning message will bring up documentation on how to address it.
With our Zen Cart upgrade service, we now include resolving any issues being warned about in the “logs” directory at no additional cost. If there is a interest in a service for dealing with those separate from an upgrade, please contact us.