0

I have been struggling with this for past one hour. I am using WAMP Local server on windows maching so everything is under my control. I am getting maximum execution time 60 seconds error when trying to import Wordpress xml file.

I have set these values in php.ini:

max_execution_time = 1200
memory_limit = 512M
max_input_time = -1

I have also edited my wp-config file : set_time_limit(0);

I restarted server after making changes. Still I get error

) Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\xxa\wp-includes\wp-db.php on line 1285

Thanks Ahmar

6
  • This file in error keeps changing every time I try to import. So I am sure it is not coming from this particular file. Commented Sep 5, 2014 at 6:47
  • 1
    Do a phpinfo() to make sure the values from your custom ini file are actually parsed. You may need to name the file differently (like php5.ini or user.ini) Commented Sep 5, 2014 at 6:47
  • Does phpinfo() show the same ini file being used? the one you updated? Commented Sep 5, 2014 at 6:49
  • Yes they do: max_execution_time 1200 1200 max_file_uploads 20 20 max_input_nesting_level 64 64 max_input_time -1 -1 max_input_vars 2500 2500 memory_limit 512M 512M Commented Sep 5, 2014 at 6:50
  • This issue has to do with your PHP configuration. Look for the ‘php.ini’ file. If you're using XAMPP is in the xampp folder, inside the php folder. This is the path: C:\xampp\php\php.ini If you are on shared hosting, you will have to ask your provider. Go to the lines dealing with the Maximum execution time of each script, in seconds (do a text search for "max_execution_time") and then change the following line: max_execution_time = 60 to something longer, like: max_execution_time = 600 Commented Sep 5, 2014 at 6:58

3 Answers 3

3

This must have something to do with the hard coded max_execution_time set to 60.

I had the same issue with the WordPress Importer. Turned out it was because of the hard coded @set_time_limit( 60 ) in the wp-includes/functions.php file:

function wp_get_http( $url, $file_path = false, $red = 1 ) { @set_time_limit( 60 );

I commented out the set_time_limit( 60 ) call and it worked fine after that:

//@set_time_limit( 60 );

Sign up to request clarification or add additional context in comments.

Comments

0

This problem can arise when the inital check performed by the plugin takes more than 30 seconds.

Please try either:

  1. Adapting the wp-config.php: set_time_limit(60);

Important – If you are making changes in wp-config.php, then add this line above the “/* That’s all, stop editing! Happy blogging. */” comment.

  1. Adapting the /.htaccess file of your WordPress installation php_value max_execution_time 60

  2. Adapting the php.ini file max_execution_time = 60;

Preferably the changes are made in the wp-config.php file.

Please let me know if that solves the issue.

Thanks

Comments

0

I had to test register_shutdown_function() myself -- I didn't think it'd run. After all, how can a user function run once there's no more memory, or execution time has elapsed? I was surprised to learn that shutdown functions do run, even in an OOM situation, or when execution time has been exceded. Proof of concept: To test memory limit:

<?php
function asdf() { echo "omg\n"; }
register_shutdown_function('asdf');

ini_set('memory_limit', '1000');

$x = '';
while(true) {
 $x .= 'lkajsdlfkjasldkfjlaskdfjasldkfj';
}

Output:

PHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to allocate 169540 bytes) in /home/scratch.php on line 9
PHP Stack trace:
PHP   1. {main}() /home/scratch.php:0

Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 169540 bytes) in /home/scratch.php on line 9

Call Stack:
    0.0002      81360   1. {main}() /home/scratch.php:0

omg

To test execution time:

cat scratch.php
<?php
function asdf() { echo "omg\n"; }
register_shutdown_function('asdf');

set_time_limit(1);

while(true) {}

Output:

PHP Fatal error:  Maximum execution time of 1 second exceeded in /home/scratch.php on line 7
PHP Stack trace:
PHP   1. {main}() /home/scratch.php:0

Fatal error: Maximum execution time of 1 second exceeded in /home/scratch.php on line 7

Call Stack:
    0.0002      80200   1. {main}() /home/scratch.php:0

omg

Note that, to get your message to display before PHP's error output, you'd have to disable PHP's error output entirely. Which is best practice for a production site anyway.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.