I am trying to import a Wordpress theme unit test xml with default wordpress importer plugin. I get following error:
Fatal error: Maximum execution time of 60 seconds exceeded in E:\XAMPP\htdocs\wp\wp-includes\wp-db.php
This is a basic Wordpress 4.5.1 installation with no additional plugins or themes, except wordpress importer v 0.6.1, on my local XAMPP server, execution time limit is set to 6000 in php.ini and I can see this preset in xampp's php_info. I've already tried adding set_time_limit(6000) in wp-config.php and wp-db.php with the same ugly error as result.
Any ideas why is this happening and how can it be helped?
You can add it in your php.ini
set_time_limit(0);
It will surely solve the problem.
I found the precise reason why this error happens, so I'll try to provide the answer to my own question.
There is a function called wp_get_http in wp-includes/deprecated.php, which is still used by the wordpress importer plugin (inside wordpress-importer.php source file). Inside this function set_time_limit(60) is called, it is the one of exactly two calls to this function with parameter 60 in all the wordpress source code, so this is the place that limits importer execution time to 60 seconds.
wp_get_http is called by importer plugin rather late in the execution flow, so it overrides any other possible set_time_limit() calls in wp-config.php, and cannot be corrected by modifications in php.ini, which on their own may happen to be not allowed by hosting provider.
The quick solution to this, which worked for me, is to modify the set_time_limit call inside wp_get_http() in wp-includes/deprecated.php, like this:
It gives the wordpress importer 20 minutes to fetch all the remote files it may require during import. May be this is not the safest solution, but it worked for me.
Add this to your .htaccess file
This to your wp-config.php
That's because your file upload time in
php.ini
is set to60 seconds
while WordPress demands more time to upload that data properly. As time end inphp.ini
so it throws that error. Solution is that you have to increase your upload time that suits you.replace that code line with your own php.ini file's code line and your problem will be resolved. If issues persists, you can increase that number 300 to even more until your files upload properly. For further reading visit http://php.net/manual/en/function.set-time-limit.php
just go to the wp-config file and paste this set_time_limit(60); or just change the figure in the parentheses to your desired choice.