Development,  WordPress

WP_Import has a deprecated constructor in…

Some of you gets this annoying notice:

Methods with the same name as their class will not be constructors in a future version of PHP; WP_Import has a deprecated constructor in …\public_html\wp-content\plugins\wordpress-importer\wordpress-importer.php

This happens if you set your WP_DEBUG constant to true, use PHP7 and run WordPress import plugin. It is only a notice, but still it is annoying. What to do? Well, this is the rarest case, when you have to enter into source-code. Why? Well, fist of all, we need to make a very small change. Second, those change won’t in fact change anything here. And last but not least – even if this plugin will be updated, it won’t broke anything. And hopefully this notice will be eliminated anyway.

So, let’s dive into source!

Find your \wp-content\plugins\wordpress-importer\ directory and localize wordpress-importer.php file. You may use your favorite text editor, many kinds of file transfer protocols or WordPress built-in editor. Find line 66:

and change it into:

and that’s it! This notice won’t appear again.

All right, but how about:

Warning: Declaration of WP_Import::bump_request_timeout() should be compatible with WP_Importer::bump_request_timeout($val) in …\public_html\wp-content\plugins\wordpress-importer\wordpress-importer.php on line 38

As far as I know, this issue is fixed in a /trunc on WordPress Importer plugin but it hasn’t been released yet as a new plugin release. But this one is also very easy. Same location, same file, go and find line 1110:

then change it to:

And that’s all folks!

PS: you may see those notices happens on your developer / home server. If you can see it in the working environment, you must know that this kind of thing just cannot happens. Your developer / home WordPress installation should have WP_DEBUG to on, and should show all errors, because you need to avoid them. But your production installation must hide everything possible!

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *