Post Pic

WordPress upgrade : Allow more time for slow servers

WordPress auto download/install is a very nice feature, but sometimes a few problems can appear. One of them is that WordPress don’t manage to download the new version. This happens on slow servers. Here is how to solve it.

To apply this hack, you'll have to edit one of WordPress core files. Keep in mind that it is never recommended. This hack should be applied only if you have problems while auto-upgrading WordPress.

Open the wp-admin/includes/files.php file and go to line 448. You'll see the following:

$response = wp_remote_get($url, array('timeout' => 60));

To allow more downloading time, simply change the 60 with a greater value, as for example:

$response = wp_remote_get($url, array('timeout' => 120));

16 Responses

Oct 28 2009 10:37

Hmm. I wonder why this couldn’t be overridden by calling the change in your functions.php and avoid changing the core files?

Oct 28 2009 10:45

What are symptoms that this is the reason?

There are indeed plenty of things that could go wrong. Last time upgrade was failing for me because WP run out of memory while at it. Got it by error log.

Oct 28 2009 13:06

Changing core files is never an option, actually. ;-)

Oct 28 2009 18:20

I haven’t tried this yet though it would be best practice if one could either update functions.php or create a plugin to do this.
One question I do have is do you know if you if alternatively you could update the actual php.ini settings file via php’s ini_set(‘max_execution_time’,120)? If you could do this then just add it to your functions.php file; I haven’t look into if it’s possible yet but if someone has the time to check it out then let us know.

Oct 28 2009 18:30

I looked at code properly. Function this fix is for uses some deprecated stuff (Snoopy class) and marked as in need of change to WP HTTP API.

So not much sense in inventing workarounds for it, at least not until code update.

Oct 28 2009 21:21

Scratch my previous comment. :) Function was updated, I got confused by outdated developer’s comment on it.

Oct 29 2009 11:08

Great job.

Oct 29 2009 11:58

What are the cons of this workaround? Is it safe?

Oct 30 2009 05:34

I have been working on a WP site that is on a diff host than usual and I can’t get it to upgrade the core, only the plugins.

I have tried upping the memory like in this post http://digwp.com/2009/06/wordpress-configuration-tricks/ still says “installation failed.”

That it will automatically upgrade plugins just fine may mean it is just a size issue, any ideas or alternative fixes?

Nov 10 2009 11:16

this is interesting! but i nowadays nobody needs this i think….
60 seconds are enough..
my opinion :)

Nov 14 2009 18:27

I found this fantastic piece of code.
Since I am storing one of my WP blogs abroad , I was having resopns tome problems. Yur solutiond helped me to solve that problem.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required