Solving the warnings generated by Suffusion on servers with PHP 7+

Feb 112018
 
 Posted by on 11/02/2018 How-To's Tagged with: ,  Add comments

People who’s upgrading the php on their servers to php 7.x will see their error log full of deprecated notices like this:

PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Suffusion_Widgets has a deprecated constructor in /home/……../public_html/wp-content/themes/suffusion/widgets/suffusion-widgets.php on line 10

With PHP 5 was introduced the constructor method:

In that version of php, for preserving the backward compatibility with versions 3 and 4, if PHP cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class. So, in PHP 3, 4 or 5, the user not see any warning in logs, as both constructors are accepted.

But, with php 7.0, the old method was deprecated, hence the notices which appear in error logs. For now, they are harmless, are just notices, the site still works fine. But in the future, the site will crash when the old method will become obsolete.

The fix is very simple. In each file which is mentioned by notices, need to replace the constructor which is the function named as it’s class, with __construct() function. This implies all files from /suffusion/widgets/ and the file theme-options-renderer.php from /suffusion/admin/ folder.

The users who’s switched to PHP 5.x or 7.x, and are concerned by these warnings can download the fix from: 

Suffusion files for PHP7

The zip contain the changed files, within their respective subdirectories of “suffusion” folder. Un-zip, and upload the files in the same structure, overwriting the files from server.

If you accidentally upgrade the files on a server with PHP<5 (presuming that your site still works now in such environment), there will be no problem. I kept the old constructors in the files, so the new files should work on any version of PHP, from 3 to 7. The last solution was inspired by Christian Weiske.

The next article is about other PHP notices solved and will find a link for downloading a full patched theme: Suffusion 4.5.1.

https://drafie-design.nl/solving-the-warnings-generated-by-suffusion-on-servers-with-php-7/trackback/Trackback URI:  

Ciprian

Experienced web developer and graphic designer. Former consultant for Suffusion theme and former moderator on Suffusion Support forum. I teach others while learning myself.

Google+ Profile

    Google+ Page

 Leave a Reply

(Your comment will be published. To contact me privately, use the contact form.)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  4 Responses to “Solving the warnings generated by Suffusion on servers with PHP 7+”

Comments (4)
  1. Hi Lennart,

    1. The errors was seen when someone had activated debug mode in wp-config.
    2. Suffusion 4.5.4. and 4.5.6. already contain the fix, don’t need to touch anything.

     
  2. Hi!

    Two questions…

    1) Where do I find the error log mentioned in this article “Solving the warnings generated by Suffusion on servers with PHP 7+”?

    2) Is this fix only needed for Suffusion 4.4.9 and earlier or is it necessary to apply it on 4.5.4 and 4.5.6 as well?

    Best regards,

    /LS

     
  3. Thanks Colin,

    Suffusion users was very lucky to have you around, last year. I watched the forum, but I didn’t had time to comment.
    But I am still here, trying to add my small contribution when I can.

    Ciprian

     
  4. Drake,

    Thanks very much for doing this for all the Suffusion users.