Wordpress importer error: max execution time 60 se

2020-07-24 05:27发布

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?

5条回答
家丑人穷心不美
2楼-- · 2020-07-24 05:58

You can add it in your php.ini

set_time_limit(0);

It will surely solve the problem.

查看更多
孤傲高冷的网名
3楼-- · 2020-07-24 06:05

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:

set_time_limit(1200); // Limit to 20 minutes

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.

查看更多
Rolldiameter
4楼-- · 2020-07-24 06:07

Add this to your .htaccess file

<IfModule mod_php5.c>
php_value post_max_size 16M
php_value upload_max_filesize 16M
php_value memory_limit 128M
php_value max_execution_time 300
php_value max_input_time 300
php_value session.gc_maxlifetime 900
</IfModule>

This to your wp-config.php

define('WP_MEMORY_LIMIT', '128M');
查看更多
放我归山
5楼-- · 2020-07-24 06:11

That's because your file upload time in php.ini is set to 60 seconds while WordPress demands more time to upload that data properly. As time end in php.ini so it throws that error. Solution is that you have to increase your upload time that suits you.

set_time_limit(300); //it will update your time to 300 seconds or 5 minutes.
max_execution_time(300);

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

查看更多
小情绪 Triste *
6楼-- · 2020-07-24 06:13

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.

查看更多
登录 后发表回答